From b0330425088c3c890522d32b5be4180f87c54d5b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 6 Jan 2008 18:12:17 +0100 Subject: [PATCH] Added support for the "status" command to the init script. --- debian/collectd.init.d | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/debian/collectd.init.d b/debian/collectd.init.d index 42a90cd..18ece44 100755 --- a/debian/collectd.init.d +++ b/debian/collectd.init.d @@ -78,6 +78,24 @@ d_stop() { fi } +d_status() { + PID=$( cat "$PIDFILE" 2> /dev/null ) || true + + if test -n "$PID" && kill -0 $PID 2> /dev/null; then + echo "collectd ($PID) is running." + exit 0 + else + PID=$( pidof collectd ) || true + + if test -n "$PID"; then + echo "collectd ($PID) is running." + exit 0 + else + echo "collectd is stopped." + fi + fi +} + case "$1" in start) echo -n "Starting $DESC: $NAME" @@ -89,6 +107,9 @@ case "$1" in d_stop echo "." ;; + status) + d_status + ;; restart|force-reload) echo -n "Restarting $DESC: $NAME" d_stop -- 2.30.2