#! /bin/sh

# $FreeBSD: tags/RELEASE_8_4_0/www/openacs/files/dotlrn.in 300897 2012-07-14 14:29:18Z beat $
#
# PROVIDE: dotlrn
# REQUIRE: DAEMON NETWORKING SERVERS
# KEYWORD: shutdown
#
# 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
rcvar=dotlrn_enable

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}

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"
