[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Make init script work with chkconfig; make it put pids in /...



Update of /home/or/cvsroot/contrib
In directory moria.mit.edu:/tmp/cvs-serv29953/contrib

Modified Files:
	tor.sh.in 
Log Message:
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)

Index: tor.sh.in
===================================================================
RCS file: /home/or/cvsroot/contrib/tor.sh.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tor.sh.in	17 Feb 2004 00:55:29 -0000	1.1
+++ tor.sh.in	27 Feb 2004 00:07:33 -0000	1.2
@@ -1,10 +1,21 @@
 #!/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
-TORARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
+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 @@
         RETVAL=1
     else 
         echo -n "Starting tor..."
-        $TORBIN -f $TORCONF $TORARGS
+        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"