5 # Required-Start: $local_fs, $remote_fs, $network, $named, $time
6 # Required-Stop: $local_fs, $remote_fs, $network, $named, $time
7 # Should-Start: $syslog
9 # Default-Start: 2 3 4 5
11 # Short-Description: Starts The Onion Router daemon processes
12 # Description: Start The Onion Router, a TCP overlay
13 # network client that provides anonymous
19 PATH
=/usr
/local
/sbin
:/usr
/local
/bin
:/sbin
:/bin
:/usr
/sbin
:/usr
/bin
23 TORPIDDIR
=/var
/run
/tor
24 TORPID
=$TORPIDDIR/tor.pid
25 DEFAULTSFILE
=/etc
/default
/$NAME
28 MAX_FILEDESCRIPTORS
=8192
31 test -x $DAEMON ||
exit 0
33 # Include tor defaults if available
34 if [ -f $DEFAULTSFILE ] ; then
38 wait_for_deaddaemon
() {
43 if kill -0 $pid 2>/dev
/null
47 while kill -0 $pid 2>/dev
/null
50 if [ $cnt -gt $WAITFORDAEMON ]
64 if test ! -d $TORPIDDIR; then
65 echo "There is no $TORPIDDIR directory. Creating one for you."
66 mkdir
-m 02700 "$TORPIDDIR"
67 chown debian-tor
:debian-tor
"$TORPIDDIR"
70 if test ! -x $TORPIDDIR; then
71 echo "Cannot access $TORPIDDIR directory, are you root?" >&2
78 if [ "$RUN_DAEMON" != "yes" ]; then
79 echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
83 if [ -n "$MAX_FILEDESCRIPTORS" ]; then
84 echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
85 if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
92 echo "Starting $DESC: $NAME..."
93 if ! su
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
94 echo "ABORTED: Tor configuration invalid:" >&2
95 su
-c "$DAEMON --verify-config" debian-tor
>&2
99 start-stop-daemon
--start --quiet --oknodo \
100 --chuid debian-tor
:debian-tor \
103 --exec $DAEMON -- $ARGS
107 echo -n "Stopping $DESC: "
108 pid
=`cat $TORPID 2>/dev/null` || true
110 if test ! -f $TORPID -o -z "$pid"; then
111 echo "not running (there is no $TORPID)."
115 if start-stop-daemon
--stop --signal INT
--quiet --pidfile $TORPID --exec $DAEMON; then
116 wait_for_deaddaemon
$pid
118 elif kill -0 $pid 2>/dev
/null
120 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
122 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
126 echo -n "Reloading $DESC configuration: "
127 pid
=`cat $TORPID 2>/dev/null` || true
129 if test ! -f $TORPID -o -z "$pid"; then
130 echo "not running (there is no $TORPID)."
134 if ! su
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
135 echo "ABORTED: Tor configuration invalid:" >&2
136 su
-c "$DAEMON --verify-config" debian-tor
>&2
140 if start-stop-daemon
--stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
143 elif kill -0 $pid 2>/dev
/null
145 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
147 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
151 if ! su
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
152 echo "Restarting Tor ABORTED: Tor configuration invalid:" >&2
153 su
-c "$DAEMON --verify-config" debian-tor
>&2
162 echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2