#!/bin/bash
### BEGIN INIT INFO
# Provides:          xvm-munin-remote-config
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: XVM Munin config
# Description:       
### END INIT INFO

NAME=xvm-munin-remote-config
PARENTPACKAGE=munin-node
GEN_FILES=/etc/munin/munin-node.conf.xvm

dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0

. /lib/init/gen-files.sh
. /lib/init/std-init.sh

do_start () {
    gen_files
    
    mako-render /usr/share/xvm-munin-remote-config/loggrep_remctl.mako >/etc/munin/plugin-conf.d/loggrep_remctl
    
    for p in "${PARENTPACKAGE[@]}"; do
        invoke-rc.d "$p" restart
    done
}

do_reload() {
    do_start
}

do_stop() {
    for p in "${PARENTPACKAGE[@]}"; do
        invoke-rc.d "$p" stop
    done
}

std_init "$1"
