fontconfig: needs host-gperf
[buildroot-gz.git] / package / transmission / S92transmission
blobe5976b0cfba0da16add3df8a918d9f8fe7cfe7ad
1 #!/bin/sh
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
10 # Do NOT "set -e"
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
26 # on this user
27 USERNAME=transmission
30 # ----- *ADVANCED* CONFIGURATION -----
31 # Only change these options if you know what you are doing!
33 # The folder where Transmission stores the config & web files.
34 # ONLY change this you have it at a non-default location
35 #TRANSMISSION_HOME="/var/config/transmission-daemon"
36 #TRANSMISSION_WEB_HOME="/usr/share/transmission/web"
38 # The arguments passed on to transmission-daemon.
39 # ONLY change this you need to, otherwise use the
40 # settings file as per above.
41 #TRANSMISSION_ARGS=""
44 # ----- END OF CONFIGURATION -----
46 # PATH should only include /usr/* if it runs after the mountnfs.sh script.
47 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
48 DESC="bittorrent client"
49 NAME=transmission-daemon
50 DAEMON=$(which $NAME)
51 PIDFILE=/var/run/$NAME.pid
52 SCRIPTNAME=/etc/init.d/$NAME
54 # Exit if the package is not installed
55 [ -x "$DAEMON" ] || exit 0
57 # Read configuration variable file if it is present
58 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
60 # Load the VERBOSE setting and other rcS variables
61 [ -f /etc/default/rcS ] && . /etc/default/rcS
64 # Function that starts the daemon/service
67 start()
69 # Export the configuration/web directory, if set
70 if [ -n "$TRANSMISSION_HOME" ]; then
71 export TRANSMISSION_HOME
73 if [ -n "$TRANSMISSION_WEB_HOME" ]; then
74 export TRANSMISSION_WEB_HOME
77 # Return
78 # 0 if daemon has been started
79 # 1 if daemon was already running
80 # 2 if daemon could not be started
81 start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
82 --exec $DAEMON --background --test -- -f $TRANSMISSION_ARGS > /dev/null \
83 || return 1
84 start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
85 --exec $DAEMON --background -- -f $TRANSMISSION_ARGS \
86 || return 2
90 # Function that stops the daemon/service
92 stop()
94 # Return
95 # 0 if daemon has been stopped
96 # 1 if daemon was already stopped
97 # 2 if daemon could not be stopped
98 # other if a failure occurred
99 start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME
100 RETVAL="$?"
101 [ "$RETVAL" = 2 ] && return 2
103 # Wait for children to finish too if this is a daemon that forks
104 # and if the daemon is only ever run from this initscript.
105 # If the above conditions are not satisfied then add some other code
106 # that waits for the process to drop all resources that could be
107 # needed by services started subsequently. A last resort is to
108 # sleep for some time.
110 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
111 [ "$?" = 2 ] && return 2
113 # Many daemons don't delete their pidfiles when they exit.
114 rm -f $PIDFILE
116 return "$RETVAL"
119 case "$1" in
120 start)
121 echo "Starting $DESC" "$NAME..."
122 start
123 case "$?" in
124 0|1) echo " Starting $DESC $NAME succeeded" ;;
125 *) echo " Starting $DESC $NAME failed" ;;
126 esac
128 stop)
129 echo "Stopping $DESC $NAME..."
130 stop
131 case "$?" in
132 0|1) echo " Stopping $DESC $NAME succeeded" ;;
133 *) echo " Stopping $DESC $NAME failed" ;;
134 esac
136 restart|force-reload)
138 # If the "reload" option is implemented then remove the
139 # 'force-reload' alias
141 echo "Restarting $DESC $NAME..."
142 stop
143 case "$?" in
144 0|1)
145 start
146 case "$?" in
147 0|1) echo " Restarting $DESC $NAME succeeded" ;;
148 *) echo " Restarting $DESC $NAME failed: couldn't start $NAME" ;;
149 esac
152 echo " Restarting $DESC $NAME failed: couldn't stop $NAME" ;;
153 esac
156 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
157 exit 3
159 esac