#!/bin/sh

# PROVIDE: mtad
# REQUIRE: NETWORKING
#
# Add the following line to /etc/rc.conf[.local] to enable mtad
#
# mtad_enable (bool):		Set to "NO" by default.
#                               Set it to "YES" to enable mtad.

. /etc/rc.subr

name="mtad"
rcvar=mtad_enable

load_rc_config $name

: ${mtad_enable="NO"}
: ${mtad_chdir="%%DATADIR%%"}
: ${mtad_config="%%ETCDIR%%/mtaserver.conf"}
: ${mtad_logfile="/var/log/mtaserver.log"}

command="%%DATADIR%%/mtaserver"
command_args="-b -c ${mtad_config} -l ${mtad_logfile} 2>&1 > /dev/null &"
required_files=${mtad_config}
start_precmd="mtad_prestart"
stop_precmd="mtad_prestop"

mtad_prestart() {
    if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then
	err 1 "Linux support required"
    fi
}

mtad_prestop() {
    rc_pid=`echo $rc_pid | awk '{print $1}'`
}
    		    
run_rc_command "$1"
