#!/bin/sh DAEMON=collectd DAEMON_CONFIG="/tmp/flash/collectd/collectd.conf" DAEMON_LONG_NAME="Collectd daemon" . /etc/init.d/modlibrc config() { mkdir -p /var/lib/collectd rm /var/mod/etc/graph 2>/dev/null if [ -z "$COLLECTD_GRAPHDIR" ]; then echo "Error: Collectd graph dir is not set, aborting..." exit 255 fi ln -s $(echo "$COLLECTD_GRAPHDIR" | sed 's/\/*$//g') /var/mod/etc/graph 2>/dev/null } start() { modreg status collectd $(lang de:"Statistik" en:"Statistics") view modlib_startdaemon $DAEMON -C $DAEMON_CONFIG -P $PID_FILE } stop_post() { [ "$1" == "0" ] && modunreg status collectd view } case $1 in ""|load) mkdir -p /tmp/flash/$DAEMON [ ! -e "$DAEMON_CONFIG" ] && modlib_config modreg cgi 'collectd' 'Collectd' modreg daemon collectd modreg file collectd conf 'collectd.conf' 1 "collectd_conf" modlib_start $COLLECTD_ENABLED ;; unload) modunreg daemon collectd modunreg file collectd modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0