[packages] collectd: use start-stop-daemon for service invokation
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 28 Feb 2010 01:50:39 +0000 (01:50 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 28 Feb 2010 01:50:39 +0000 (01:50 +0000)
SVN-Revision: 19887

utils/collectd/files/collectd.init

index 4ec4771bed38f3d8e94770708686cd77a25be4b7..6204eabaa40fa4b1737d8504828c48bb72a25a78 100644 (file)
@@ -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
+       }
 }