#!/bin/sh

# PROVIDE: mrtg_daemon
# REQUIRE: DAEMON bsnmpd snmpd
# KEYWORD: shutdown

. /etc/rc.subr


name="mrtg_daemon"
rcvar=mrtg_daemon_enable

load_rc_config $name

: ${mrtg_daemon_enable="NO"}
: ${mrtg_daemon_pidfile="/var/run/mrtg/mrtg.pid"}
: ${mrtg_daemon_user="mrtg"}
: ${mrtg_daemon_group="mrtg"}
: ${mrtg_daemon_config="%%ETCDIR%%/mrtg.cfg"}

: ${mrtg_daemon_flags="--pid-file $mrtg_daemon_pidfile --lock-file /var/run/mrtg/lockfile --confcache-file /var/run/mrtg/confcache --user $mrtg_daemon_user --group $mrtg_daemon_group --daemon $mrtg_daemon_config"}

start_precmd="mrtg_daemon_precmd"

command="%%PREFIX%%/bin/mrtg"
command_interpreter="%%PERL%%"
pidfile=${mrtg_daemon_pidfile}

mrtg_daemon_precmd()
{
       rm -f /var/run/mrtg/lockfile /var/run/mrtg/confcache $mrtg_daemon_pidfile
       export LANG=C
}

run_rc_command "$1"
