The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / transmission / S92transmission
1 #!/bin/sh
2
3 # Original Author: Lennart A. Jtte, based on Rob Howell's script
4 # Modified by Maarten Van Coile & others (on IRC)
5
6 # Changes for buildroot:
7 # USERNAME points to 'default' in standard installation
8 # TODO: set logfile with --logfile option
9
10 # Do NOT "set -e"
11
12 #
13 # ----- CONFIGURATION -----
14 #
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
21 #
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
28 USERNAME=default
29
30
31
32 # ----- *ADVANCED* CONFIGURATION -----
33 # Only change these options if you know what you are doing!
34 #
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"
39 #
40 # The arguments passed on to transmission-daemon.
41 # ONLY change this you need to, otherwise use the
42 # settings file as per above.
43 #TRANSMISSION_ARGS=""
44
45
46 # ----- END OF CONFIGURATION -----
47 #
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
52 DAEMON=$(which $NAME)
53 PIDFILE=/var/run/$NAME.pid
54 SCRIPTNAME=/etc/init.d/$NAME
55
56 # Exit if the package is not installed
57 [ -x "$DAEMON" ] || exit 0
58
59 # Read configuration variable file if it is present
60 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
61
62 # Load the VERBOSE setting and other rcS variables
63 [ -f /etc/default/rcS ] && . /etc/default/rcS
64
65 #
66 # Function that starts the daemon/service
67 #
68
69 start()
70 {
71     # Export the configuration/web directory, if set
72     if [ -n "$TRANSMISSION_HOME" ]; then
73           export TRANSMISSION_HOME
74     fi
75     if [ -n "$TRANSMISSION_WEB_HOME" ]; then
76           export TRANSMISSION_WEB_HOME
77     fi
78
79     # Return
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 \
85             || return 1
86     start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
87             --exec $DAEMON --background -- -f $TRANSMISSION_ARGS \
88             || return 2
89 }
90
91 #
92 # Function that stops the daemon/service
93 #
94 stop()
95 {
96         # Return
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
102         RETVAL="$?"
103         [ "$RETVAL" = 2 ] && return 2
104
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.
111
112         start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
113         [ "$?" = 2 ] && return 2
114
115         # Many daemons don't delete their pidfiles when they exit.
116         rm -f $PIDFILE
117
118         return "$RETVAL"
119 }
120
121 case "$1" in
122   start)
123         echo "Starting $DESC" "$NAME..."
124         start
125         case "$?" in
126                 0|1) echo "   Starting $DESC $NAME succeeded" ;;
127                 *)   echo "   Starting $DESC $NAME failed" ;;
128         esac
129         ;;
130   stop)
131         echo "Stopping $DESC $NAME..."
132         stop
133         case "$?" in
134                 0|1) echo "   Stopping $DESC $NAME succeeded" ;;
135                 *)   echo "   Stopping $DESC $NAME failed" ;;
136         esac
137         ;;
138   restart|force-reload)
139         #
140         # If the "reload" option is implemented then remove the
141         # 'force-reload' alias
142         #
143         echo "Restarting $DESC $NAME..."
144         stop
145         case "$?" in
146           0|1)
147                 start
148                 case "$?" in
149                     0|1) echo "   Restarting $DESC $NAME succeeded" ;;
150                     *)   echo "   Restarting $DESC $NAME failed: couldn't start $NAME" ;;
151                 esac
152                 ;;
153           *)
154                 echo "   Restarting $DESC $NAME failed: couldn't stop $NAME" ;;
155         esac
156         ;;
157   *)
158         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
159         exit 3
160         ;;
161 esac