3 # skeleton example file to build /etc/init.d/ scripts.
4 # This file should be used to construct scripts for /etc/init.d.
6 # Written by Miquel van Smoorenburg <miquels@cistron.nl>.
8 # by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9 # Further changes by Javier Fernandez-Sanguino <jfs@debian.org>
11 # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
14 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
15 DAEMON=/usr/sbin/freeside
19 test -x $DAEMON || exit 0
21 LOGDIR=/var/log/freeside
22 PIDFILE=/var/run/$NAME.pid
23 DODTIME=1 # Time to wait for the server to die, in seconds
24 # If this value is set too low you might not
25 # let some servers to die gracefully and
26 # 'restart' will not work
28 # Include freeside defaults if available
29 if [ -f /etc/default/freeside ] ; then
30 . /etc/default/freeside
37 # Check if a given process pid's cmdline matches a given name
40 [ -z "$pid" ] && return 1
41 [ ! -d /proc/$pid ] && return 1
42 cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
43 # Is this the expected child?
44 [ "$cmd" != "$name" ] && return 1
50 # Check if the process is running looking at /proc
51 # (works for all users)
53 # No pidfile, probably no daemon present
54 [ ! -f "$PIDFILE" ] && return 1
55 # Obtain the pid and check it against the binary name
57 running_pid $pid $NAME || return 1
62 # Forcefully kill the process
63 [ ! -f "$PIDFILE" ] && return
67 [ -n "$DODTIME" ] && sleep "$DODTIME"s
70 [ -n "$DODTIME" ] && sleep "$DODTIME"s
72 echo "Cannot kill $LABEL (pid=$pid)!"
83 echo -n "Starting $DESC: "
84 start-stop-daemon --start --quiet --pidfile $PIDFILE \
85 --exec $DAEMON -- $DAEMON_OPTS
93 echo -n "Stopping $DESC: "
94 start-stop-daemon --stop --quiet --pidfile $PIDFILE \
99 echo -n "Forcefully stopping $DESC: "
109 # If the daemon can reload its config files on the fly
110 # for example by sending it SIGHUP, do it here.
112 # If the daemon responds to changes in its config file
113 # directly anyway, make this a do-nothing entry.
115 # echo "Reloading $DESC configuration files."
116 # start-stop-daemon --stop --signal 1 --quiet --pidfile \
117 # /var/run/$NAME.pid --exec $DAEMON
121 # If the "reload" option is implemented, move the "force-reload"
122 # option to the "reload" entry above. If not, "force-reload" is
123 # just the same as "restart" except that it does nothing if the
124 # daemon isn't already running.
125 # check wether $DAEMON is running. If so, restart
126 start-stop-daemon --stop --test --quiet --pidfile \
127 /var/run/$NAME.pid --exec $DAEMON \
132 echo -n "Restarting $DESC: "
133 start-stop-daemon --stop --quiet --pidfile \
134 /var/run/$NAME.pid --exec $DAEMON
135 [ -n "$DODTIME" ] && sleep $DODTIME
136 start-stop-daemon --start --quiet --pidfile \
137 /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
151 # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
152 echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2