updated on Sat Jan 21 16:18:39 UTC 2012
[aur-mirror.git] / transmission-svn / transmissiond
blobce71b6546f6a2a26259a979510e478fea8b8b852
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/conf.d/transmissiond
7 if [ "$(id -u)" != 0 ]
8 then
9 echo "You must be root to start Transmission as daemon."
10 exit 2
13 if [ -z $TRANS_USER ]
14 then
15 echo "Unable to run Transmission. You must set the user in /etc/conf.d/transmissiond"
16 exit 2
19 confdir=$(su -l $TRANS_USER -c "echo ~")/.transmission
20 if [ ! -d $confdir ]; then
21 su -l $TRANS_USER -c "mkdir -p $confdir"
24 PID=`pidof -o %PPID /usr/bin/transmission-daemon`
25 case "$1" in
26 start)
27 stat_busy "Starting Transmission Daemon"
28 [ -z "$PID" ] && su -l $TRANS_USER -c "/usr/bin/transmission-daemon"
29 if [ ! -z "$PID" -o $? -gt 0 ]; then
30 stat_fail
31 else
32 add_daemon transmissiond
33 stat_done
36 stop)
37 stat_busy "Stopping Transmission Daemon"
39 [ ! -z "$PID" ] && kill $PID &> /dev/null
40 if [ $? -gt 0 ]; then
41 stat_fail
42 else
43 rm_daemon transmissiond
44 stat_done
47 restart)
48 $0 stop
49 sleep 1
50 $0 start
53 echo "usage: $0 {start|stop|restart}"
54 esac
55 exit 0