#! /bin/sh
#
#
# PROVIDE: dotlrn
# REQUIRE: DAEMON NETWORKING SERVERS
#
# Add the following line to /etc/rc.conf to enable dotlrn:
#
# dotlrn_enable="YES"
#
# Tweakable parameters for users to override in rc.conf

. "/etc/rc.subr"

name=dotlrn

load_rc_config ${name}
: ${dotlrn_enable="NO"}
: ${dotlrn_user="dotlrn"}
: ${dotlrn_group="dotlrn"}
: ${dotlrn_conf=/usr/local/dotlrn/etc/dotlrn-config.tcl}
: ${dotlrn_flags="-u ${dotlrn_user} -g ${dotlrn_group}"}
: ${dotlrn_prog=/usr/local/aolserver/bin/nsd}
: ${dotlrn_pidfile=/var/run/dotlrn.pid}

rcvar=`set_rcvar`
pidfile=${dotlrn_pidfile}
start_postcmd="start_postcmd"
stop_postcmd="stop_postcmd"
required_files=${dotlrn_conf}
command=/usr/local/aolserver/bin/nsd
command_args="-t ${dotlrn_conf}"
procname=${dotlrn_prog}

start_postcmd()
{
	PID=`pgrep -U ${dotlrn_user} -f ${dotlrn_conf}`
	[ -n "${PID}" ] && echo ${PID} > ${pidfile}
}

stop_postcmd()
{
	[ -f "${pidfile}" ] && rm ${pidfile}
}

run_rc_command "$1"
