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 ]
65 if test ! -d $TORPIDDIR; then
66 echo "There is no $TORPIDDIR directory. Creating one for you."
67 mkdir
-m 02700 "$TORPIDDIR"
68 chown debian-tor
:debian-tor
"$TORPIDDIR"
71 if test ! -x $TORPIDDIR; then
72 echo "Cannot access $TORPIDDIR directory, are you root?" >&2
80 if [ "$RUN_DAEMON" != "yes" ]; then
81 echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
85 if [ -n "$MAX_FILEDESCRIPTORS" ]; then
86 echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
87 if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
96 echo "Starting $DESC: $NAME..."
97 if ! su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
98 echo "ABORTED: Tor configuration invalid:" >&2
99 su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
>&2
103 start-stop-daemon
--start --quiet --oknodo \
104 --chuid debian-tor
:debian-tor \
107 --exec $DAEMON -- $ARGS
111 echo -n "Stopping $DESC: "
112 pid
=`cat $TORPID 2>/dev/null` || true
114 if test ! -f $TORPID -o -z "$pid"; then
115 echo "not running (there is no $TORPID)."
119 if start-stop-daemon
--stop --signal INT
--quiet --pidfile $TORPID --exec $DAEMON; then
120 wait_for_deaddaemon
$pid
122 elif kill -0 $pid 2>/dev
/null
124 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
126 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
130 echo -n "Reloading $DESC configuration: "
131 pid
=`cat $TORPID 2>/dev/null` || true
133 if test ! -f $TORPID -o -z "$pid"; then
134 echo "not running (there is no $TORPID)."
138 if ! su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
139 echo "ABORTED: Tor configuration invalid:" >&2
140 su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
>&2
144 if start-stop-daemon
--stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
147 elif kill -0 $pid 2>/dev
/null
149 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
151 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
155 if ! su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
> /dev
/null
; then
156 echo "Restarting Tor ABORTED: Tor configuration invalid:" >&2
157 su
-s /bin
/sh
-c "$DAEMON --verify-config" debian-tor
>&2
166 echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2