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
=4096
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 [ "$RUN_DAEMON" != "yes" ]; then
66 echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
68 if test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
69 elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
71 echo "Starting $DESC: $NAME..."
72 ulimit -n $MAX_FILEDESCRIPTORS ||
echo "Warn: Could not set ulimit for number of file descriptors." >&2
73 start-stop-daemon
--start --quiet --oknodo \
74 --chuid debian-tor
:debian-tor \
77 --exec $DAEMON -- $ARGS
83 echo -n "Stopping $DESC: "
84 pid
=`cat $TORPID 2>/dev/null` || true
85 if test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
86 elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
87 elif test ! -f $TORPID -o -z "$pid"
89 echo "not running (there is no $TORPID)."
90 elif start-stop-daemon
--stop --signal INT
--quiet --pidfile $TORPID --exec $DAEMON
92 wait_for_deaddaemon
$pid
94 elif kill -0 $pid 2>/dev
/null
96 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
98 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
102 echo -n "Reloading $DESC configuration: "
103 pid
=`cat $TORPID 2>/dev/null` || true
104 if test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
105 elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
106 elif test ! -f $TORPID -o -z "$pid"
108 echo "not running (there is no $TORPID)."
109 elif start-stop-daemon
--stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
112 elif kill -0 $pid 2>/dev
/null
114 echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
116 echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
125 echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2