#!/bin/sh
#
# PROVIDE: dccifd
# REQUIRE: LOGIN
# BEFORE: mail
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable dccifd:
#
#dccifd_enable="YES"
#
# See dccifd(8) for flags
#

. /etc/rc.subr

name=dccifd
rcvar=`set_rcvar`

load_rc_config $name

# Set defaults
: ${dccifd_enable:="NO"}
: ${dccifd_flags=""}
: ${dccifd_home="/usr/local/dcc"}
: ${dccifd_conf="$dccifd_home/dcc_conf"}


pidfile=${dccifd_pidfile:-"/var/run/dcc/dccifd.pid"}
command="${dccifd_home}/libexec/start-dccifd"
procname="${dccifd_home}/libexec/dccifd"
required_dirs="$dccifd_home"
required_files="${dccifd_conf}"

stop_postcmd="stop_postcmd"
start_precmd="start_precmd"


stop_postcmd()
{
 rm -f $pidfile
}

start_precmd()
{
X=`grep DCCIFD_ENABLE ${dccifd_conf}`
eval $X
if [ "$DCCIFD_ENABLE"  != "on" ]
then
	echo "Warning ${X} needs to be on in ${dccifd_conf}"
	return 1
fi
}

run_rc_command "$1"

