[or-cvs] Slightly improve init script to give you proper error messa...

Peter Palfrader weasel at seul.org
Fri Jul 29 10:01:56 UTC 2005


Update of /home/or/cvsroot/tor/debian
In directory moria:/tmp/cvs-serv19896/debian

Modified Files:
      Tag: tor-0_1_0-patches
	changelog tor.init 
Log Message:
Slightly improve init script to give you proper error messages when you do not run it as root.


Index: changelog
===================================================================
RCS file: /home/or/cvsroot/tor/debian/changelog,v
retrieving revision 1.120.2.8
retrieving revision 1.120.2.9
diff -u -d -r1.120.2.8 -r1.120.2.9
--- changelog	19 Jul 2005 18:55:04 -0000	1.120.2.8
+++ changelog	29 Jul 2005 10:01:54 -0000	1.120.2.9
@@ -1,3 +1,10 @@
+tor (0.1.0.XXXX) unstable; urgency=low
+
+  * Slightly improve init script to give you proper error messages when
+    you do not run it as root.
+
+ -- Peter Palfrader <weasel at debian.org>  Fri, 29 Jul 2005 12:01:16 +0200
+
 tor (0.1.0.12-1) unstable; urgency=medium
 
   * New upstream version:

Index: tor.init
===================================================================
RCS file: /home/or/cvsroot/tor/debian/tor.init,v
retrieving revision 1.13.2.1
retrieving revision 1.13.2.2
diff -u -d -r1.13.2.1 -r1.13.2.2
--- tor.init	10 Jun 2005 16:08:13 -0000	1.13.2.1
+++ tor.init	29 Jul 2005 10:01:54 -0000	1.13.2.2
@@ -6,7 +6,8 @@
 DAEMON=/usr/sbin/tor
 NAME=tor
 DESC="tor daemon"
-TORPID=/var/run/tor/tor.pid
+TORPIDDIR=/var/run/tor
+TORPID=$TORPIDDIR/tor.pid
 DEFAULTSFILE=/etc/default/$NAME
 WAITFORDAEMON=60
 ARGS=""
@@ -50,20 +51,26 @@
 	if [ "$RUN_DAEMON" != "yes" ]; then
 		echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
 	else
-		echo "Starting $DESC: $NAME..."
-		ulimit -n $MAX_FILEDESCRIPTORS || echo "Warn: Could not set ulimit for number of file descriptors." >&2
-		start-stop-daemon --start --quiet --oknodo \
-			--chuid debian-tor:debian-tor \
-			--pidfile $TORPID \
-			$NICE \
-			--exec $DAEMON -- $ARGS
-		echo "done."
+		if   test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
+		elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
+		else
+			echo "Starting $DESC: $NAME..."
+			ulimit -n $MAX_FILEDESCRIPTORS || echo "Warn: Could not set ulimit for number of file descriptors." >&2
+			start-stop-daemon --start --quiet --oknodo \
+				--chuid debian-tor:debian-tor \
+				--pidfile $TORPID \
+				$NICE \
+				--exec $DAEMON -- $ARGS
+			echo "done."
+		fi
 	fi
 	;;
   stop)
 	echo -n "Stopping $DESC: "
 	pid=`cat $TORPID 2>/dev/null` || true
-	if test ! -f $TORPID -o -z "$pid"
+	if   test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
+	elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
+	elif test ! -f $TORPID -o -z "$pid"
 	then
 		echo "not running (there is no $TORPID)."
 	elif start-stop-daemon --stop --signal INT --quiet --pidfile $TORPID --exec $DAEMON
@@ -80,7 +87,9 @@
   reload|force-reload)
 	echo -n "Reloading $DESC configuration: "
 	pid=`cat $TORPID 2>/dev/null` || true
-	if test ! -f $TORPID -o -z "$pid"
+	if   test ! -d $TORPIDDIR; then echo "There is no $TORPIDDIR directory." >&2; exit 1
+	elif test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
+	elif test ! -f $TORPID -o -z "$pid"
 	then
 		echo "not running (there is no $TORPID)."
 	elif start-stop-daemon --stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON



More information about the tor-commits mailing list