5 # chkconfig: 2345 90 10
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"
65 if [ -f $TORPID ]; then
66 echo -n "Sending HUP to tor..."
67 kill -HUP `cat $TORPID`
69 if [ $RETVAL -eq 0 ]; then
75 echo "Unable to kill tor: $TORPID does not exist"
82 if [ -f $TORPID ]; then
90 PID
=`cat $TORPID 2>/dev/null`
91 if [ "$PID" != "" ]; then
92 torstat
=`ps -p $PID | grep -c "^$PID"`
94 echo "tor is running ($PID)"
96 echo "tor is not running (looks like it crashed, look for core? $PID)"
99 echo "tor is not running (exited gracefully)"
108 echo "Usage: $0 (start|stop|restart|status|log)"