4
# Required-Start: $remote_fs $network
5
# Required-Stop: $remote_fs $network
6
# Default-Start: 2 3 4 5
8
# Short-Description: Init script for ziproxy
9
# Description: This is the init script for ziproxy.
12
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
13
DAEMON=/usr/bin/ziproxy
17
test -x $DAEMON || exit 0
19
PIDFILE=/var/run/$NAME.pid
20
DODTIME=1 # Time to wait for the server to die, in seconds
21
# If this value is set too low you might not
22
# let some servers to die gracefully and
23
# 'restart' will not work
25
if [ ! -d /var/run ]; then
29
# Include ziproxy defaults if available
30
if [ -f /etc/default/ziproxy ] ; then
31
. /etc/default/ziproxy
33
DAEMON_OPTS="$DAEMON_OPTS -d -p $PIDFILE"
38
# Check if a given process pid's cmdline matches a given name
41
[ -z "$pid" ] && return 1
42
[ ! -d /proc/$pid ] && return 1
43
cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
44
# Is this the expected child?
45
##[ "$cmd" != "$name" ] && return 1
46
[ "$cmd" != "$name" ] && return 1
51
# Check if the process is running looking at /proc
52
# (works for all users)
54
# No pidfile, probably no daemon present
55
[ ! -f "$PIDFILE" ] && return 1
56
# Obtain the pid and check it against the binary name
58
if ! running_pid $pid $DAEMON; then
66
# Forcefully kill the process
67
[ ! -f "$PIDFILE" ] && return
71
[ -n "$DODTIME" ] && sleep "$DODTIME"s
74
[ -n "$DODTIME" ] && sleep "$DODTIME"s
76
echo "Cannot kill $NAME (pid=$pid)!"
87
echo "$NAME is not running."
95
[ $off_echo ] || echo -n "Starting $DESC: "
97
echo "$NAME is already running."
100
start-stop-daemon --start --quiet --pidfile $PIDFILE \
101
--exec $DAEMON -- $DAEMON_OPTS
103
[ $off_echo ] || echo "$NAME."
112
[ $off_echo ] || echo -n "Stopping $DESC: "
113
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
115
[ -f $PIDFILE ] && rm $PIDFILE
116
[ $off_echo ] || echo "$NAME."
127
echo -n "Forcefully stopping $DESC: "
136
restart|force-reload)
137
echo -n "Restarting $DESC: "
140
[ -n "$DODTIME" ] && sleep $DODTIME
155
echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2