From 0b95e987b195350158b17b5bca999f9cfd9a1124 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 1 Mar 2008 00:49:03 +0000 Subject: Move config check to its own function svn:r13787 --- debian/tor.init | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'debian') diff --git a/debian/tor.init b/debian/tor.init index 38712ceb7..29af4d2ee 100644 --- a/debian/tor.init +++ b/debian/tor.init @@ -89,6 +89,14 @@ check_torpiddir () { fi } +check_config () { + if ! su -s /bin/sh -c "$DAEMON --verify-config" debian-tor > /dev/null; then + echo "ABORTED: Tor configuration invalid:" >&2 + su -s /bin/sh -c "$DAEMON --verify-config" debian-tor >&2 + exit 1 + fi +} + case "$1" in start) @@ -109,11 +117,7 @@ case "$1" in check_torpiddir echo "Starting $DESC: $NAME..." - if ! su -s /bin/sh -c "$DAEMON --verify-config" debian-tor > /dev/null; then - echo "ABORTED: Tor configuration invalid:" >&2 - su -s /bin/sh -c "$DAEMON --verify-config" debian-tor >&2 - exit 1 - fi + check_config start-stop-daemon --start --quiet --oknodo \ --pidfile $TORPID \ @@ -149,11 +153,7 @@ case "$1" in exit 0 fi - if ! su -s /bin/sh -c "$DAEMON --verify-config" debian-tor > /dev/null; then - echo "ABORTED: Tor configuration invalid:" >&2 - su -s /bin/sh -c "$DAEMON --verify-config" debian-tor >&2 - exit 1 - fi + check_config if start-stop-daemon --stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON then @@ -166,11 +166,7 @@ case "$1" in fi ;; restart) - if ! su -s /bin/sh -c "$DAEMON --verify-config" debian-tor > /dev/null; then - echo "Restarting Tor ABORTED: Tor configuration invalid:" >&2 - su -s /bin/sh -c "$DAEMON --verify-config" debian-tor >&2 - exit 1 - fi + check_config $0 stop sleep 1 -- cgit v1.2.3