From ab79790550878d11e68811f7df3e7fbfb13a0795 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 5 Feb 2008 23:14:13 +0100 Subject: [PATCH] debian/collectd.init.d: Use the correct pid-file during shut-down. Slightly simplified the handling of different setups. --- debian/collectd.init.d | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/debian/collectd.init.d b/debian/collectd.init.d index de14e35..0fa14d8 100755 --- a/debian/collectd.init.d +++ b/debian/collectd.init.d @@ -49,22 +49,19 @@ if test "$DISABLE" != 0; then exit 0 fi -get_pid() { - if test "$USE_COLLECTDMON" == 1; then - cat "$COLLECTDMON_PIDFILE" - else - cat "$PIDFILE" - fi -} +if test "$USE_COLLECTDMON" == 1; then + _PIDFILE="$COLLECTDMON_PIDFILE" +else + _PIDFILE="$PIDFILE" +fi d_start() { if test "$USE_COLLECTDMON" == 1; then - start-stop-daemon --start --quiet --pidfile "$COLLECTDMON_PIDFILE" \ - --exec $COLLECTDMON_DAEMON -- -P "$COLLECTDMON_PIDFILE" -- \ - -C "$CONFIGFILE" + start-stop-daemon --start --quiet --pidfile "$_PIDFILE" \ + --exec $COLLECTDMON_DAEMON -- -P "$_PIDFILE" -- -C "$CONFIGFILE" else - start-stop-daemon --start --quiet --pidfile "$PIDFILE" \ - --exec $DAEMON -- -C "$CONFIGFILE" -P "$PIDFILE" + start-stop-daemon --start --quiet --pidfile "$_PIDFILE" \ + --exec $DAEMON -- -C "$CONFIGFILE" -P "$_PIDFILE" fi } @@ -74,9 +71,9 @@ In large setups it might take some time to write all pending data to the disk. You can adjust the waiting time in /etc/default/collectd." d_stop() { - PID=$( get_pid 2> /dev/null ) || true + PID=$( cat "$_PIDFILE" 2> /dev/null ) || true - start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" + start-stop-daemon --stop --quiet --oknodo --pidfile "$_PIDFILE" sleep 1 if test -n "$PID" && kill -0 $PID 2> /dev/null; then @@ -97,7 +94,7 @@ d_stop() { } d_status() { - PID=$( get_pid 2> /dev/null ) || true + PID=$( cat "$_PIDFILE" 2> /dev/null ) || true if test -n "$PID" && kill -0 $PID 2> /dev/null; then echo "collectd ($PID) is running." -- 2.30.2