6 #description: Onion Router
11 TORPID
=@LOCALSTATEDIR@
/run
/tor
/tor.pid
12 TORLOG
=@LOCALSTATEDIR@
/log
/tor
/tor.log
13 TORCONF
=@CONFDIR@
/torrc
14 # Strictly speaking, we don't need to su if we have --user and --group.
15 # "Belt and suspenders," says jbash.
16 TORARGS
="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
17 if [ "x$TORUSER" != "x" ]; then
18 TORARGS
="$TORARGS --user $TORUSER"
20 if [ "x$TORGROUP" != "x" ]; then
21 TORARGS
="$TORARGS --group $TORGROUP"
28 if [ -f $TORPID ]; then
29 echo "tor appears to be already running (pid file exists)"
30 echo "Maybe you should run: $0 restart ?"
33 echo -n "Starting tor..."
34 if [ "x$TORUSER" = "x" ]; then
35 $TORBIN -f $TORCONF $TORARGS
37 /bin
/su
-c "$TORBIN -f $TORCONF $TORARGS" $TORUSER
40 if [ $RETVAL -eq 0 ]; then
49 if [ -f $TORPID ]; then
50 echo -n "Killing tor..."
53 if [ $RETVAL -eq 0 ]; then
59 echo "Unable to kill tor: $TORPID does not exist"
66 if [ -f $TORPID ]; then
73 PID
=`cat $TORPID 2>/dev/null`
74 if [ "$PID" != "" ]; then
75 torstat
=`ps -p $PID | grep -c "^$PID"`
77 echo "tor is running ($PID)"
79 echo "tor is not running (looks like it crashed, look for core? $PID)"
82 echo "tor is not running (exited gracefully)"
91 echo "Usage: $0 (start|stop|restart|status|log)"