5 PATH
=/usr
/local
/sbin
:/usr
/local
/bin
:/sbin
:/bin
:/usr
/sbin
:/usr
/bin
9 TORLOG
=/var
/log
/tor
/log
10 TORPID
=/var
/run
/tor
/tor.pid
11 DEFAULTSFILE
=/etc
/default
/$NAME
13 ARGS
="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
15 test -x $DAEMON ||
exit 0
17 # Include tor defaults if available
18 if [ -f $DEFAULTSFILE ] ; then
22 wait_for_deaddaemon
() {
27 if kill -0 $pid 2>/dev
/null
31 while kill -0 $pid 2>/dev
/null
34 if [ $cnt -gt $WAITFORDAEMON ]
49 if [ "$RUN_DAEMON" != "yes" ]; then
50 echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
52 echo -n "Starting $DESC: "
53 start-stop-daemon
--start --quiet --oknodo \
54 --chuid debian-tor
:debian-tor \
56 --exec $DAEMON -- $ARGS
61 echo -n "Stopping $DESC: "
62 pid
=`cat $TORPID 2>/dev/null` || true
63 if test ! -f $TORPID -o -z "$pid"
65 echo "not running (there is no $TORPID)."
66 elif start-stop-daemon
--stop --quiet --pidfile $TORPID --exec $DAEMON
68 wait_for_deaddaemon
$pid
70 elif kill -0 $pid 2>/dev
/null
72 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
74 echo "FAILED ($DAEMON died: process $pid not running)."
78 echo -n "Reloading $DESC configuration: "
79 pid
=`cat $TORPID 2>/dev/null` || true
80 if test ! -f $TORPID -o -z "$pid"
82 echo "not running (there is no $TORPID)."
83 elif start-stop-daemon
--stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
86 elif kill -0 $pid 2>/dev
/null
88 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
90 echo "FAILED ($DAEMON died: process $pid not running)."
99 echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2