aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-02-27 00:07:33 +0000
committerNick Mathewson <nickm@torproject.org>2004-02-27 00:07:33 +0000
commit40a8b340dae9ea1927b6f624113b335a28d728a9 (patch)
treec9dad4b286e10c7a23ab6ac90fb6f1cf60c7b494
parent17f40b21a72763f1b2a3ec229b8a0dee7f02ce7f (diff)
downloadtor-40a8b340dae9ea1927b6f624113b335a28d728a9.tar
tor-40a8b340dae9ea1927b6f624113b335a28d728a9.tar.gz
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
-rw-r--r--contrib/tor.sh.in21
1 files changed, 18 insertions, 3 deletions
diff --git a/contrib/tor.sh.in b/contrib/tor.sh.in
index ecf3cb32d..a3ffaaa39 100644
--- a/contrib/tor.sh.in
+++ b/contrib/tor.sh.in
@@ -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 @@ case "$1" in
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"