#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2010 OpenWrt.org
START=80
BINARY="/usr/sbin/collectd"
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
+ }
}