X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=debian%2Fcollectd.init.d;h=7c8ac291c50f28dab151b6120d88e76d96f09d9d;hb=2794e703be245165757b0bec50a6ba09ae5417f0;hp=200647154382496348a6ba11b191d08e90452748;hpb=2c3e089616d7fa356a3c950a13758b23dab0633b;p=collectd.git diff --git a/debian/collectd.init.d b/debian/collectd.init.d index 20064715..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 @@ -14,6 +15,10 @@ DAEMON=/usr/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME ARGS="" +CONFIGDIR=/etc/collectd +# for backward compatibility +FALLBACKCONF=/etc/collectd.conf + # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 @@ -22,32 +27,55 @@ then . /etc/default/$NAME fi -if [ -n "$DATA_DIR" ]; then - ARGS="-D $DATA_DIR" -fi - -if [ -n "$PING_HOST" ]; then - for HOST in $PING_HOST - do - ARGS="$ARGS -p $HOST" - done -fi - # # Function that starts the daemon/service. # d_start() { - if [ "x$START_SERVER" = "xyes" ] - then - $DAEMON -s $ARGS - fi - if [ "x$START_CLIENT" = "xyes" ] - then - $DAEMON -c $ARGS - fi - if [ "x$START_SERVER" != "xyes" -a "x$START_CLIENT" != "xyes" ] + i=0 + + if [ ! -d "$CONFIGDIR" ] then - start-stop-daemon --start --quiet --exec $DAEMON -- -l $ARGS + 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 } @@ -55,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 @@ -84,4 +112,4 @@ esac exit 0 -# vim:syntax=sh +# vim: syntax=sh noexpandtab sw=8 ts=8 :