updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / cbtt80 / cbtt.rc.d
blob7f7f21c0f0c615025a84d39354448d16ed69802b
1 #!/bin/bash
3 # Start/stop/restart script for CBTT, the C++ BitTorrent tracker
4 # Unfortunately, since the tracker's binary itself is written to output
5 # data to terminal by default (and there's no known way to override this,
6 # at least to me), we have to use dtach, what results in some quite
7 # unnecessary checking whether the server is actually running or not.
8 # If somebody has a better idea on how to do this, please contact me.
10 . /etc/rc.d/functions
12 case "$1" in
13 start)
14 stat_busy "Starting CBTT"
15 if [ -e /home/tracker/bnbtconsole ];
16 then
17 rm -f /home/tracker/bnbtconsole
19 if [ ! -z `pidof bnbt` ];
20 then
21 stat_fail
22 else
23 su - -c "dtach -n bnbtconsole /home/tracker/bnbt" tracker
24 if [ -z `pidof bnbt` ];
25 then
26 stat_fail
27 else
28 add_daemon cbtt
29 stat_done
33 stop)
34 stat_busy "Stopping CBTT"
35 if [ -z `pidof bnbt` ];
36 then
37 stat_fail
38 else
39 kill `pidof bnbt`
40 rm_daemon cbtt
41 stat_done
44 restart)
45 $0 stop
46 $0 start
49 echo "Usage : $0 {start|stop|restart}"
51 esac