X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=debian%2Fcollectd.init.d;h=7e7731cd7e2f9457c87194533df782019191071e;hb=fc7eb7321d83aeec9660ca0571fce4340257235d;hp=200647154382496348a6ba11b191d08e90452748;hpb=257828f628523077c73c858744e1e93f0231304a;p=collectd.git diff --git a/debian/collectd.init.d b/debian/collectd.init.d index 20064715..7e7731cd 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,45 @@ 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" -a -e "$FALLBACKCONF" ] then - start-stop-daemon --start --quiet --exec $DAEMON -- -l $ARGS + start-stop-daemon --start --quiet --exec $DAEMON \ + -- -C "$FALLBACKCONF" + 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]"; + else + echo -n ")" + fi fi }