Code

collectd.init.d: Only use /etc/collectd/collectd.conf as config file.
authorSebastian Harl <sh@tokkee.org>
Sun, 20 May 2007 01:38:36 +0000 (03:38 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 20 May 2007 01:38:36 +0000 (03:38 +0200)
Because of the new plugin infrastructure, a single config file suffices. As
we're now shipping collection.conf in /etc/collectd/ we do not want the init
script to look for multiple config files.

debian/collectd.init.d

index 525b3f5cbfb02515779d17aea4f18629818b2e19..8e9c981c273fa62d9192f0438094701443ebf9b6 100755 (executable)
 
 set -e
 
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DESC="Statistics collection daemon"
 NAME=collectd
 DAEMON=/usr/sbin/$NAME
 SCRIPTNAME=/etc/init.d/$NAME
 ARGS=""
 
-CONFIGDIR=/etc/collectd
-# for backward compatibility
-FALLBACKCONF=/etc/collectd.conf
+CONFIGFILE=/etc/collectd/collectd.conf
 
 # Gracefully exit if the package has been removed.
 test -x $DAEMON || exit 0
 
-if [ -r /etc/default/$NAME ]
-then
+if [ -r /etc/default/$NAME ]; then
        . /etc/default/$NAME
 fi
 
-#
-#      Function that starts the daemon/service.
-#
 d_start() {
-       i=0
-       
-       if [ ! -d "$CONFIGDIR" ]
-       then
-               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
+       if [ -f "$CONFIGFILE" ]; then
+               $DAEMON -C $CONFIGFILE 2> /dev/null
        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
+               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
 }
 
-#
-#      Function that stops the daemon/service.
-#
 d_stop() {
        start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
 }
 
 case "$1" in
-  start)
-       echo -n "Starting $DESC: $NAME"
-       d_start
-       echo "."
-       ;;
-  stop)
-       echo -n "Stopping $DESC: $NAME"
-       d_stop
-       echo "."
-       ;;
-  restart|force-reload)
-       echo -n "Restarting $DESC: $NAME"
-       d_stop
-       sleep 1
-       d_start
-       echo "."
-       ;;
-  *)
-       echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
-       exit 1
-       ;;
+       start)
+               echo -n "Starting $DESC: $NAME"
+               d_start
+               echo "."
+               ;;
+       stop)
+               echo -n "Stopping $DESC: $NAME"
+               d_stop
+               echo "."
+               ;;
+       restart|force-reload)
+               echo -n "Restarting $DESC: $NAME"
+               d_stop
+               sleep 1
+               d_start
+               echo "."
+               ;;
+       *)
+               echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+               exit 1
+               ;;
 esac
 
 exit 0
 
-# vim: syntax=sh noexpandtab sw=8 ts=8 :
+# vim: syntax=sh noexpandtab sw=4 ts=4 :