3 # Original Author: Lennart A. Jtte, based on Rob Howell's script
4 # Modified by Maarten Van Coile & others (on IRC)
6 # Changes for buildroot:
7 # USERNAME points to 'default' in standard installation
8 # TODO: set logfile with --logfile option
13 # ----- CONFIGURATION -----
15 # For the default location Transmission uses, visit:
16 # http://trac.transmissionbt.com/wiki/ConfigFiles
17 # For a guide on how set the preferences, visit:
18 # http://trac.transmissionbt.com/wiki/EditConfigFiles
19 # For the available environement variables, visit:
20 # http://trac.transmissionbt.com/wiki/EnvironmentVariables
22 # The name of the user that should run Transmission.
23 # It's RECOMENDED to run Transmission in it's own user,
24 # by default, this is set to 'transmission'.
25 # For the sake of security you shouldn't set a password
27 #USERNAME=transmission
32 # ----- *ADVANCED* CONFIGURATION -----
33 # Only change these options if you know what you are doing!
35 # The folder where Transmission stores the config & web files.
36 # ONLY change this you have it at a non-default location
37 #TRANSMISSION_HOME="/var/config/transmission-daemon"
38 #TRANSMISSION_WEB_HOME="/usr/share/transmission/web"
40 # The arguments passed on to transmission-daemon.
41 # ONLY change this you need to, otherwise use the
42 # settings file as per above.
46 # ----- END OF CONFIGURATION -----
48 # PATH should only include /usr/* if it runs after the mountnfs.sh script.
49 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
50 DESC="bittorrent client"
51 NAME=transmission-daemon
53 PIDFILE=/var/run/$NAME.pid
54 SCRIPTNAME=/etc/init.d/$NAME
56 # Exit if the package is not installed
57 [ -x "$DAEMON" ] || exit 0
59 # Read configuration variable file if it is present
60 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
62 # Load the VERBOSE setting and other rcS variables
63 [ -f /etc/default/rcS ] && . /etc/default/rcS
66 # Function that starts the daemon/service
71 # Export the configuration/web directory, if set
72 if [ -n "$TRANSMISSION_HOME" ]; then
73 export TRANSMISSION_HOME
75 if [ -n "$TRANSMISSION_WEB_HOME" ]; then
76 export TRANSMISSION_WEB_HOME
80 # 0 if daemon has been started
81 # 1 if daemon was already running
82 # 2 if daemon could not be started
83 start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
84 --exec $DAEMON --background --test -- -f $TRANSMISSION_ARGS > /dev/null \
86 start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
87 --exec $DAEMON --background -- -f $TRANSMISSION_ARGS \
92 # Function that stops the daemon/service
97 # 0 if daemon has been stopped
98 # 1 if daemon was already stopped
99 # 2 if daemon could not be stopped
100 # other if a failure occurred
101 start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME
103 [ "$RETVAL" = 2 ] && return 2
105 # Wait for children to finish too if this is a daemon that forks
106 # and if the daemon is only ever run from this initscript.
107 # If the above conditions are not satisfied then add some other code
108 # that waits for the process to drop all resources that could be
109 # needed by services started subsequently. A last resort is to
110 # sleep for some time.
112 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
113 [ "$?" = 2 ] && return 2
115 # Many daemons don't delete their pidfiles when they exit.
123 echo "Starting $DESC" "$NAME..."
126 0|1) echo " Starting $DESC $NAME succeeded" ;;
127 *) echo " Starting $DESC $NAME failed" ;;
131 echo "Stopping $DESC $NAME..."
134 0|1) echo " Stopping $DESC $NAME succeeded" ;;
135 *) echo " Stopping $DESC $NAME failed" ;;
138 restart|force-reload)
140 # If the "reload" option is implemented then remove the
141 # 'force-reload' alias
143 echo "Restarting $DESC $NAME..."
149 0|1) echo " Restarting $DESC $NAME succeeded" ;;
150 *) echo " Restarting $DESC $NAME failed: couldn't start $NAME" ;;
154 echo " Restarting $DESC $NAME failed: couldn't stop $NAME" ;;
158 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2