#!/bin/sh

# PROVIDE: inadyn
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# inadyn_enable (bool):		Set it to "YES" to enable inadyn
#				Default is "NO"
# inadyn_config (str):		Set full path to configuration file.
#				Default is "/usr/local/etc/inadyn.conf"
# inadyn_pidfile (str):		Set full path to pid file.
#				Default is "/var/run/inadyn/inadyn.pid"
#

. /etc/rc.subr

name="inadyn"
rcvar=inadyn_enable

start_precmd="inadyn_checkconfig"
restart_precmd="inadyn_checkconfig"
configtest_precmd="inadyn_checkconfig"
extra_commands="configtest"

load_rc_config $name

: ${inadyn_enable:="NO"}
: ${inadyn_config:="/usr/local/etc/inadyn.conf"}
: ${inadyn_pidfile:="/var/run/inadyn/inadyn.pid"}

command=/usr/local/sbin/inadyn
command_args="-p inadyn:inadyn -f ${inadyn_config} -P ${inadyn_pidfile}"
pidfile=${inadyn_pidfile}
required_files=${inadyn_config}

inadyn_checkconfig()
{
	echo "Performing sanity check on ${name} configuration:"
	eval ${command} ${command_args} --check-config
}

run_rc_command "$1"
