делаем автозапуск xbtt на Debian и CentOS
создаем скрипт запуска
nano /etc/init.d/xbtt
!!!ВАЖНО!!!!
XBT_PATH=»/home/xbt» — это путь до Вашего собранного трекера.
1. Debian :
#!/bin/sh
XBT_PATH="/home/xbt"
start() {
echo "Starting XBT Tracker"
start-stop-daemon --start --quiet --exec $XBT_PATH/xbt_tracker -- --conf_file $XBT_PATH/xbt_tracker.conf
echo $?
}
stop() {
echo "Stopping XBT Tracker"
start-stop-daemon --stop --quiet --pidfile /var/run/xbt.pid
echo $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 1
2. CentOS
#!/bin/sh
#
# xbt Start/Stop the XBT Tracker
#
# chkconfig: 2345 99 01
#
# description: The XBT Tracker
# Source function library.
. /etc/init.d/functions
set -e
# *** CHANGE THE BELOW DEFAULT VALUES TO REFLECT YOUR SYSTEM ***
# Defaults
TRACKERDIR=/home/xbtt
DAEMON=/usr/local/bin/xbt_tracker
CONFFILE=/home/xbtt/xbt_tracker.conf
PIDFILE=/home/xbtt/xbt_tracker.pid
USER=xbtt
# Sanity checks -- note you'll get no output from the first two if they
# error!
test -f $DAEMON || exit 0
test -r $CONFFILE || exit 0
if ! id $USER >/dev/null 2>&1; then
echo "$0: $USER user does not exist! You probably should run this as a regular user or your Apache user."
exit 1
fi
# Insist the config file is chmod 600 and owned by the correct user
if [ "`stat -c '%U %a' $CONFFILE 2>/dev/null`" != "$USER 600" ]; then
chown -h $USER $CONFFILE
chmod -f 0600 $CONFFILE
fi
# Insist the daemon has sane ownerships and permissions
chown -h $USER $DAEMON
chmod -f 0700 $DAEMON
case "$1" in
start)
echo -n "Starting BitTorrent tracker: XBT Tracker"
# run the tracker as the tracker user
cd $TRACKERDIR
su - $USER -c $DAEMON
;;
stop)
echo -n "Stopping BitTorrent tracker: XBT Tracker"
# change to the tracker's subdirectory and kill it
cd $TRACKERDIR
kill `cat $PIDFILE`
# wait a bit and then take out a gun and make sure it's dead
sleep 5
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE`
fi
;;
force-reload|restart)
echo -n "Restarting BitTorrent tracker: XBT Tracker"
# change to the tracker's subdirectory and kill it
cd $TRACKERDIR
kill `cat $PIDFILE`
# wait a bit and then take out a gun and make sure it's dead
sleep 5
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE`
fi
# wait a bit and restart as our tracker user
sleep 1
cd $TRACKERDIR
su - $USER -c $DAEMON
;;
*)
echo "Usage: /etc/init.d/xbtt {start|stop|restart|force-reload}"
echo " start - starts XBT Tracker service"
echo " stop - stops XBT Tracker service"
echo " restart, force-reload - starts a new XBT Tracker service"
exit 1
;;
esac
exit 0
далее выставляем права — chmod +x /etc/init.d/xbtt
вносим в автозапуск :
update-rc.d xbt defaults 99
Tags: CentOS, Debian, xbtt