From 53ad37a2923cb5ca091d94b882b6f77c3a42b927 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 28 Feb 2010 01:50:39 +0000 Subject: [PATCH] [packages] collectd: use start-stop-daemon for service invokation SVN-Revision: 19887 --- utils/collectd/files/collectd.init | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/utils/collectd/files/collectd.init b/utils/collectd/files/collectd.init index 4ec4771bed..6204eabaa4 100644 --- a/utils/collectd/files/collectd.init +++ b/utils/collectd/files/collectd.init @@ -1,5 +1,5 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2010 OpenWrt.org START=80 BINARY="/usr/sbin/collectd" @@ -7,23 +7,22 @@ PIDFILE="/var/run/collectd.pid" DATADIR="/var/lib/collectd" start() { - [ -x "$BINARY" ] || exit 1; - - if [ -e "$PIDFILE" ] - then - kill $(cat "$PIDFILE") 2>/dev/null - sleep 1 - fi - + [ -x "$BINARY" ] || exit 1 [ -d "$DATADIR" ] || mkdir -p "$DATADIR"; - $BINARY + rm -f $PIDFILE + start-stop-daemon -S -q -b -x $BINARY -m -p $PIDFILE -- -f } stop() { - kill $(cat "$PIDFILE") 2>/dev/null -} + [ -s "$PIDFILE" ] && { + local pid="$(cat $PIDFILE)" + + start-stop-daemon -K -q -n ${BINARY##*/} -p $PIDFILE -restart() { - start + for i in 1 2 3 4 5; do + kill -0 $pid 2>/dev/null || return + sleep 1 + done + } } -- 2.30.2