6 #description: Onion Router
11 TORPID
=@LOCALSTATEDIR@
/run
/tor
/tor.pid
12 TORLOG
=@LOCALSTATEDIR@
/log
/tor
/tor.log
13 TORCONF
=@CONFDIR@
/torrc
14 if [ "x$TORUSER" -eq "x" ]; then
15 TORARGS
="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
17 TORARGS
="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1 --user $TORUSER --group $TORGROUP"
24 if [ -f $TORPID ]; then
25 echo "tor appears to be already running (pid file exists)"
26 echo "Maybe you should run: $0 restart ?"
29 echo -n "Starting tor..."
30 if [ "x$TORUSER" -eq "x" ]; then
31 $TORBIN -f $TORCONF $TORARGS
33 /bin
/su
-c "$TORBIN -f $TORCONF $TORARGS" $TORUSER
36 if [ $RETVAL -eq 0 ]; then
45 if [ -f $TORPID ]; then
46 echo -n "Killing tor..."
49 if [ $RETVAL -eq 0 ]; then
55 echo "Unable to kill tor: $TORPID does not exist"
62 if [ -f $TORPID ]; then
69 PID
=`cat $TORPID 2>/dev/null`
70 if [ "$PID" != "" ]; then
71 torstat
=`ps -p $PID | grep -c "^$PID"`
73 echo "tor is running ($PID)"
75 echo "tor is not running (looks like it crashed, look for core? $PID)"
78 echo "tor is not running (exited gracefully)"
87 echo "Usage: $0 (start|stop|restart|status|log)"