the init script.
# collectd Initscript for collectd
# http://verplant.org/collectd/
# Author: Florian Forster <octo@verplant.org>
+# Extended to support multiple running instances of collectd:
+# Sebastian Harl <sh@tokkee.org>
#
set -e
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
# Function that starts the daemon/service.
#
d_start() {
- if [ -e "$CONFIG" ]
+ i=1
+
+ if [[ ! -d "$CONFIGDIR" && -e "$FALLBACKCONF" ]]
then
- start-stop-daemon --start --quiet --exec $DAEMON -- -C "$CONFIG"
+ start-stop-daemon --start --quiet --exec $DAEMON \
+ -- -C "$FALLBACKCONF"
+ else
+ echo -n " ("
+ for CONFIG in `cd $CONFIGDIR; ls *.conf 2> /dev/null`; do
+ CONF="$CONFIGDIR/$CONFIG"
+ NAME=${CONFIG%%.conf}
+ PIDFILE=$( grep PIDFile $CONF | awk '{print $2}' )
+
+ if [ 1 != $i ]; then
+ echo -n " "
+ fi
+
+ start-stop-daemon --start --quiet \
+ --pidfile $PIDFILE --startas $DAEMON \
+ -- -C "$CONFIGDIR/$CONFIG"
+ echo -n "$NAME"
+
+ let i++
+ done
+ echo -n ")"
fi
}
--- /dev/null
+#!/bin/bash -e
+# postinst script for collectd
+#
+# see: dh_installdeb(1)
+#
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+
+case "$1" in
+ configure)
+ [ -d /etc/collectd ] || mkdir -p /etc/collectd
+
+ if [ -e /etc/collectd.conf && ! -e /etc/collectd/default.conf ]; then
+ mv /etc/collectd.conf /etc/collectd/default.conf
+ fi
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
+
--- /dev/null
+#! /bin/sh
+# postrm script for collectd
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postrm> `remove'
+# * <postrm> `purge'
+# * <old-postrm> `upgrade' <new-version>
+# * <new-postrm> `failed-upgrade' <old-version>
+# * <new-postrm> `abort-install'
+# * <new-postrm> `abort-install' <old-version>
+# * <new-postrm> `abort-upgrade' <old-version>
+# * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ purge)
+ rm -rf /var/lib/collectd
+ rm -rf /etc/collectd
+ rm -f /etc/collectd.conf
+ ;;
+
+ remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0