packages/utils/collectd/files/collectd.init
jow 23183ad860 [packages] collectd: use start-stop-daemon for service invokation
git-svn-id: svn://svn.openwrt.org/openwrt/packages@19887 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-02-28 01:50:39 +00:00

29 lines
529 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2010 OpenWrt.org
START=80
BINARY="/usr/sbin/collectd"
PIDFILE="/var/run/collectd.pid"
DATADIR="/var/lib/collectd"
start() {
[ -x "$BINARY" ] || exit 1
[ -d "$DATADIR" ] || mkdir -p "$DATADIR";
rm -f $PIDFILE
start-stop-daemon -S -q -b -x $BINARY -m -p $PIDFILE -- -f
}
stop() {
[ -s "$PIDFILE" ] && {
local pid="$(cat $PIDFILE)"
start-stop-daemon -K -q -n ${BINARY##*/} -p $PIDFILE
for i in 1 2 3 4 5; do
kill -0 $pid 2>/dev/null || return
sleep 1
done
}
}