5 # chkconfig: 2345 90 10
6 # description: Onion Router
11 TORPID
=@LOCALSTATEDIR@
/run
/tor
/tor.pid
12 TORLOG
=@LOCALSTATEDIR@
/log
/tor
/tor.log
13 TORDATA
=@LOCALSTATEDIR@
/lib
/tor
15 TORCONF
=@CONFDIR@
/torrc
16 # Strictly speaking, we don't need to su if we have --user and --group.
17 # "Belt and suspenders," says jbash.
18 TORARGS
="--pidfile $TORPID --log \"notice file $TORLOG \" --runasdaemon 1 --datadirectory $TORDATA"
19 if [ "x$TORUSER" != "x" ]; then
20 TORARGS
="$TORARGS --user $TORUSER"
22 if [ "x$TORGROUP" != "x" ]; then
23 TORARGS
="$TORARGS --group $TORGROUP"
30 if [ -f $TORPID ]; then
31 echo "tor appears to be already running (pid file exists)"
32 echo "Maybe you should run: $0 restart ?"
35 echo -n "Starting tor..."
36 if [ "x$TORUSER" = "x" ]; then
37 $TORBIN -f $TORCONF $TORARGS
39 /bin
/su
-c "$TORBIN -f $TORCONF $TORARGS" $TORUSER
42 if [ $RETVAL -eq 0 ]; then
51 if [ -f $TORPID ]; then
52 echo -n "Killing tor..."
55 if [ $RETVAL -eq 0 ]; then
61 echo "Unable to kill tor: $TORPID does not exist. Assuming already dead."
67 if [ -f $TORPID ]; then
68 echo -n "Sending HUP to tor..."
69 kill -HUP `cat $TORPID`
71 if [ $RETVAL -eq 0 ]; then
77 echo "Unable to kill tor: $TORPID does not exist"
84 if [ -f $TORPID ]; then
91 PID
=`cat $TORPID 2>/dev/null`
92 if [ "$PID" != "" ]; then
93 torstat
=`ps -p $PID | grep -c "^$PID"`
95 echo "tor is running ($PID)"
97 echo "tor is not running (looks like it crashed, look for core? $PID)"
100 echo "tor is not running (exited gracefully)"
109 echo "Usage: $0 (start|stop|restart|status|log)"