updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / utserver / utserver.rc.d
blob2e5d7f77cde85e0a5aa242711c92accf8dffe500
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 . /etc/conf.d/utserver
8 PIDFILE=/var/run/utserver/utserver.pid
10 [ -r "$PIDFILE" ] && PID=$(cat "$PIDFILE")
11 [ -n "$PID" ] && PID=$(pidof -s /usr/share/utserver/utserver)
13 case "$1" in
14 start)
15 stat_busy "Starting uTorrent-server"
16 su -l -s /bin/sh -c "/usr/bin/utserver $UTSERVER_ARGS >/dev/null 2>&1" $UTSERVER_USER
17 if [ $? -gt 0 ]; then
18 stat_fail
19 else
20 add_daemon utserver
21 stat_done
24 stop)
25 stat_busy "Stopping uTorrent-server"
26 [ -n "$PID" ] && kill $PID &> /dev/null
27 if [ $? -gt 0 ]; then
28 stat_fail
29 else
30 while [ -d /proc/"$PID" ]; do
31 sleep 1
32 done
33 rm -f "$PIDFILE"
34 rm_daemon utserver
35 stat_done
38 restart)
39 $0 stop
40 $0 start
43 echo "usage: $0 {start|stop|restart}"
44 esac
45 exit 0