X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=debian%2Fcollectd.init.d;h=7c8ac291c50f28dab151b6120d88e76d96f09d9d;hb=2794e703be245165757b0bec50a6ba09ae5417f0;hp=13118fabf4136d4de344a4b222aa3284727b2a32;hpb=8d4ee27a45cc485a8690fe7a00b7c0c7d5ba5353;p=collectd.git diff --git a/debian/collectd.init.d b/debian/collectd.init.d index 13118fab..7c8ac291 100755 --- a/debian/collectd.init.d +++ b/debian/collectd.init.d @@ -1,8 +1,9 @@ -#!/bin/sh +#!/bin/bash # # collectd Initscript for collectd -# http://verplant.org/collectd/ -# Author: Florian Forster +# http://collectd.org/ +# Authors: Florian Forster +# Sebastian Harl # set -e @@ -13,7 +14,10 @@ NAME=collectd DAEMON=/usr/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME ARGS="" -CONFIG=/etc/collectd.conf + +CONFIGDIR=/etc/collectd +# for backward compatibility +FALLBACKCONF=/etc/collectd.conf # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 @@ -27,9 +31,51 @@ fi # Function that starts the daemon/service. # d_start() { - if [ -e "$CONFIG" ] + i=0 + + if [ ! -d "$CONFIGDIR" ] then - start-stop-daemon --start --quiet --exec $DAEMON -- -C "$CONFIG" + if [ -e "$FALLBACKCONF" ] + then + $DAEMON -C "$FALLBACKCONF" 2> /dev/null + else + echo "" + echo "This package is not configured yet. Please refer" + echo "to /usr/share/doc/collectd/README.Debian for" + echo "details." + echo "" + exit 0 + fi + else + for FILE in `ls $CONFIGDIR/*.conf 2>/dev/null` + do + NAME=`basename "$FILE" .conf` + + if [ $i == 0 ] + then + echo -n " (" + else + echo -n ", " + fi + + $DAEMON -C "$FILE" 2> /dev/null + if [ $? == 0 ] + then + echo -n "$NAME" + else + echo -n "$NAME failed" + fi + + i=$(($i+1)) + done + + if [ $i == 0 ] + then + echo -n "[no config found]" + exit 1 + else + echo -n ")" + fi fi } @@ -37,7 +83,7 @@ d_start() { # Function that stops the daemon/service. # d_stop() { - start-stop-daemon --stop --quiet --exec $DAEMON + start-stop-daemon --stop --quiet --oknodo --exec $DAEMON } case "$1" in @@ -66,4 +112,4 @@ esac exit 0 -# vim:syntax=sh +# vim: syntax=sh noexpandtab sw=8 ts=8 :