Commit 40a8b340 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

Make init script work with chkconfig; make it put pids in /var/run/tor (not...

Make init script work with chkconfig; make it put pids in /var/run/tor (not /var/run) and allow it to su as needed (based on tor.spec)


svn:r1133
parent 17f40b21
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
#!/bin/sh
#
#tor    The Onion Router
#
#chkconfig:2345 90 10
#description: Onion Router

TORUSER=
TORGROUP=
TORBIN=@BINDIR@/tor
TORPID=@LOCALSTATEDIR@/run/tor.pid
TORPID=@LOCALSTATEDIR@/run/tor/tor.pid
TORLOG=@LOCALSTATEDIR@/log/tor/tor.log
TORCONF=@CONFDIR@/torrc
if [ "x$TORUSER" -eq "x" ]; then
    TORARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
else
    TORARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1 --user $TORUSER --group $TORGROUP"
fi
RETVAL=0

case "$1" in
@@ -16,7 +27,11 @@ case "$1" in
        RETVAL=1
    else 
        echo -n "Starting tor..."
        if  [ "x$TORUSER" -eq "x" ]; then
            $TORBIN -f $TORCONF $TORARGS
        else 
            /bin/su -c "$TORBIN -f $TORCONF $TORARGS" $TORUSER
        fi
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
            echo " ok"