/
init
71 lines (63 loc) · 1.8 KB
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
### BEGIN INIT INFO
# Provides: transmission-daemon
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Start the transmission BitTorrent daemon client.
### END INIT INFO
DIRECTORY="/media/hdd/transmission"
DOWNLOAD_DIR="${DIRECTORY}/download"
CONFIG_DIR="${DIRECTORY}/config"
WATCH_DIR="${DIRECTORY}/watch"
RPC_PORT=9091
USER="root"
PASSWORD="enigma2"
ALLOWED="*.*.*.*,*:*:*:*:*:*:*:*"
[ -f /etc/default/transmission-daemon ] && . /etc/default/transmission-daemon
NAME="transmission-daemon"
DAEMON="/bin/nice -n 9 /usr/bin/transmission-daemon"
ARGS="-c $WATCH_DIR -g $CONFIG_DIR -r :: -a $ALLOWED -w $DOWNLOAD_DIR -p $RPC_PORT -t -u $USER -v $PASSWORD"
[ -z "$DAEMON_USER" ] || SSDOPTIONS="--chuid $DAEMON_USER:$DAEMON_GROUP"
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [ ! -d $DOWNLOAD_DIR ] ; then mkdir -p $DOWNLOAD_DIR; fi
if [ ! -d $CONFIG_DIR ] ; then mkdir -p $CONFIG_DIR; fi
if [ ! -d $WATCH_DIR ] ; then mkdir -p $WATCH_DIR; fi
case $1 in
start)
echo "Starting $NAME"
start-stop-daemon $SSDOPTIONS -S -b -n $NAME -a $DAEMON -- $ARGS
;;
stop)
echo "Stopping $NAME"
start-stop-daemon --stop --quiet --exec /usr/bin/transmission-daemon
;;
restart)
echo -n "Stopping $NAME"
start-stop-daemon --stop --quiet --exec /usr/bin/transmission-daemon
for i in 1 2 3 ; do
sleep 1
echo -n "."
done
echo
echo "Restarting $NAME"
start-stop-daemon $SSDOPTIONS -S -b -n $NAME -a $DAEMON -- $ARGS
;;
autostart | enable)
echo
update-rc.d transmission-daemon defaults 60
sleep 2
echo
;;
noautostart | disable)
echo
update-rc.d -f transmission-daemon remove
sleep 2
echo
;;
*)
echo "Usage: $0 {start|restart|stop|enable|disable}"
exit 1
esac
exit 0