#!/bin/sh

# PROVIDE: automuteus
# REQUIRE: DAEMON FILESYSTEMS NETWORKING
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable automuteus.
#
#automuteus_enable="YES"

. /etc/rc.subr

name="automuteus"
rcvar="automuteus_enable"

load_rc_config $name

: ${automuteus_enable:="NO"}
: ${automuteus_conf:="%%PREFIX%%/etc/automuteus/automuteus.conf"}
: ${automuteus_log:="/var/log/automuteus"}

command="%%PREFIX%%/bin/automuteus"
pidfile=/var/run/${name}.pid
start_cmd="automuteus_start"
stop_cmd="automuteus_stop"

automuteus_start()
{
	check_startmsgs && echo "Starting ${name}."
	source ${automuteus_conf}
	/usr/sbin/daemon \
		-p ${pidfile} \
		/usr/bin/env \
		"LOG_PATH=${automuteus_log}" \
		${command}
}

automuteus_stop()
{
	kill `cat ${pidfile}`
}

run_rc_command "$1"
