Package: tor
Version: 0.2.0.34-1
Severity: wishlist
Tags: patch

Here is a patch to support the "status" action in the init.d script.

In case you plan to use the lsb init functions sometime, you can simplify this 
a lot.
diff -u tor-0.2.0.34/debian/tor.init tor-0.2.0.34/debian/tor.init
--- tor-0.2.0.34/debian/tor.init
+++ tor-0.2.0.34/debian/tor.init
@@ -184,8 +184,26 @@
 	sleep 1
 	$0 start
 	;;
+  status)
+	if test ! -r $(dirname $TORPID); then
+		echo "cannot read tor PID file"
+		exit 4
+	fi
+	pid=`cat $TORPID 2>/dev/null` || true
+	if test ! -f $TORPID -o -z "$pid"; then
+		echo "tor is not running"
+		exit 3
+	fi
+	if ps "$pid" >/dev/null 2>&1; then
+		echo "tor is running"
+		exit 0
+	else
+		echo "tor is not running"
+		exit 1
+	fi
+	;;
   *)
-	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+	echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
 	exit 1
 	;;
 esac

Reply via email to