#!/bin/sh

# PROVIDE: dccd
# REQUIRE: LOGIN
# BEFORE: mail
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf:
#
#dccd_enable="YES"
#
# and in %%DCCHOME%%/dcc_conf change:
#
#DCCD_ENABLE=off
#
# to:
#
#DCCD_ENABLE=on
#
#
# See %%DCCHOME%%/dcc_conf to configure startup options

. /etc/rc.subr

name=dccd
rcvar=dccd_enable

load_rc_config $name

# Set defaults
: ${dccd_enable:="NO"}
: ${dccd_home="%%DCCDATA%%"}
: ${dccd_libexec="%%PREFIX%%/libexec"}
: ${dccd_conf="$dccd_home/dcc_conf"}


procname="${dccd_libexec}/dccd"
required_dirs="${dccd_home} ${dccd_libexec}"
required_files="${dccd_conf} ${dccd_libexec}/rcDCC"

start_cmd="start_dccd"
stop_cmd="stop_dccd"
start_precmd="start_precmd"


start_precmd()
{
X=`grep ^DCCD_ENABLE ${dccd_conf}`
eval $X
if [ "$DCCD_ENABLE"  != "on" ]
then
	echo "Warning ${X} needs to be on in ${dccd_conf} to start the dccd server"
	return 1
fi
}

start_dccd()
{
	echo Starting dccd.
	${dccd_libexec}/rcDCC -m dccd start
}

stop_dccd()
{
	echo Stopping dccd.
	${dccd_libexec}/rcDCC -m dccd stop
}

run_rc_command "$1"

