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"
27 if [ -x /bin
/su
] ; then
29 elif [ -x /sbin
/su
] ; then
31 elif [ -x /usr
/bin
/su
] ; then
33 elif [ -x /usr
/sbin
/su
] ; then
42 if [ -f $TORPID ]; then
43 echo "tor appears to be already running (pid file exists)"
44 echo "Maybe you should run: $0 restart ?"
47 echo -n "Starting tor..."
48 if [ "x$TORUSER" = "x" ]; then
49 $TORBIN -f $TORCONF $TORARGS
51 $SUPROG -c "$TORBIN -f $TORCONF $TORARGS" $TORUSER
54 if [ $RETVAL -eq 0 ]; then
63 if [ -f $TORPID ]; then
64 echo -n "Killing tor..."
67 if [ $RETVAL -eq 0 ]; then
73 echo "Unable to kill tor: $TORPID does not exist. Assuming already dead."
79 if [ -f $TORPID ]; then
80 echo -n "Sending HUP to tor..."
81 kill -HUP `cat $TORPID`
83 if [ $RETVAL -eq 0 ]; then
89 echo "Unable to kill tor: $TORPID does not exist"
96 if [ -f $TORPID ]; then
103 PID
=`cat $TORPID 2>/dev/null`
104 if [ "$PID" != "" ]; then
105 torstat
=`ps -p $PID | grep -c "^$PID"`
106 if [ $torstat ]; then
107 echo "tor is running ($PID)"
109 echo "tor is not running (looks like it crashed, look for core? $PID)"
112 echo "tor is not running (exited gracefully)"
121 echo "Usage: $0 (start|stop|restart|status|log)"