[or-cvs] r8299: Unnest all those nested if blocks (in tor/trunk: . debian)

weasel at seul.org weasel at seul.org
Tue Aug 29 20:43:59 UTC 2006


Author: weasel
Date: 2006-08-29 16:43:59 -0400 (Tue, 29 Aug 2006)
New Revision: 8299

Modified:
   tor/trunk/
   tor/trunk/debian/tor.init
Log:
 r9566 at galaxy:  weasel | 2006-08-29 22:32:26 +0200
 Unnest all those nested if blocks



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /local/or/tor/trunk [r9566] on 1f724f9b-111a-0410-b636-93f1a77c1813

Modified: tor/trunk/debian/tor.init
===================================================================
--- tor/trunk/debian/tor.init	2006-08-29 20:43:52 UTC (rev 8298)
+++ tor/trunk/debian/tor.init	2006-08-29 20:43:59 UTC (rev 8299)
@@ -60,52 +60,59 @@
 	return 0
 }
 
+
+if test ! -d $TORPIDDIR; then
+	echo "There is no $TORPIDDIR directory.  Creating one for you."
+	mkdir -m 02700 "$TORPIDDIR"
+	chown debian-tor:debian-tor "$TORPIDDIR"
+fi
+
+if test ! -x $TORPIDDIR; then
+	echo "Cannot access $TORPIDDIR directory, are you root?" >&2
+	exit 1
+fi
+
+
 case "$1" in
   start)
 	if [ "$RUN_DAEMON" != "yes" ]; then
 		echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
-	else
-		if test ! -d $TORPIDDIR; then
-			echo "There is no $TORPIDDIR directory.  Creating one for you."
-			mkdir -m 02700 "$TORPIDDIR"
-			chown debian-tor:debian-tor "$TORPIDDIR"
-		fi
-		if test ! -x $TORPIDDIR; then echo "Cannot access $TORPIDDIR directory, are you root?" >&2; exit 1;
+		exit 0
+	fi
+
+	if [ -n "$MAX_FILEDESCRIPTORS" ]; then
+		echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
+		if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
+			echo "."
 		else
-			if [ -n "$MAX_FILEDESCRIPTORS" ]; then
-				echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
-				if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
-					echo "."
-				else
-					echo ": FAILED."
-				fi
-			fi
-			echo "Starting $DESC: $NAME..."
-			if ! su -c "$DAEMON --verify-config" debian-tor > /dev/null; then
-				echo "ABORTED: Tor configuration invalid:" >&2
-				su -c "$DAEMON --verify-config" debian-tor >&2
-				exit 1
-			else
-				start-stop-daemon --start --quiet --oknodo \
-					--chuid debian-tor:debian-tor \
-					--pidfile $TORPID \
-					$NICE \
-					--exec $DAEMON -- $ARGS
-				echo "done."
-			fi
+			echo ": FAILED."
 		fi
 	fi
+
+	echo "Starting $DESC: $NAME..."
+	if ! su -c "$DAEMON --verify-config" debian-tor > /dev/null; then
+		echo "ABORTED: Tor configuration invalid:" >&2
+		su -c "$DAEMON --verify-config" debian-tor >&2
+		exit 1
+	fi
+
+	start-stop-daemon --start --quiet --oknodo \
+		--chuid debian-tor:debian-tor \
+		--pidfile $TORPID \
+		$NICE \
+		--exec $DAEMON -- $ARGS
+	echo "done."
 	;;
   stop)
 	echo -n "Stopping $DESC: "
 	pid=`cat $TORPID 2>/dev/null` || true
-	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
+
+	if 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
-	then
+		exit 0
+	fi
+
+	if start-stop-daemon --stop --signal INT --quiet --pidfile $TORPID --exec $DAEMON; then
 		wait_for_deaddaemon $pid
 		echo "$NAME."
 	elif kill -0 $pid 2>/dev/null
@@ -118,16 +125,19 @@
   reload|force-reload)
 	echo -n "Reloading $DESC configuration: "
 	pid=`cat $TORPID 2>/dev/null` || true
-	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
+
+	if test ! -f $TORPID -o -z "$pid"; then
 		echo "not running (there is no $TORPID)."
-	elif ! su -c "$DAEMON --verify-config" debian-tor > /dev/null; then
+		exit 0
+	fi
+
+	if ! su -c "$DAEMON --verify-config" debian-tor > /dev/null; then
 		echo "ABORTED: Tor configuration invalid:" >&2
 		su -c "$DAEMON --verify-config" debian-tor >&2
 		exit 1
-	elif start-stop-daemon --stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
+	fi
+
+	if start-stop-daemon --stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
 	then
 		echo "$NAME."
 	elif kill -0 $pid 2>/dev/null
@@ -138,6 +148,12 @@
 	fi
 	;;
   restart)
+	if ! su -c "$DAEMON --verify-config" debian-tor > /dev/null; then
+		echo "Restarting Tor ABORTED: Tor configuration invalid:" >&2
+		su -c "$DAEMON --verify-config" debian-tor >&2
+		exit 1
+	fi
+
 	$0 stop
 	sleep 1
 	$0 start



More information about the tor-commits mailing list