#!/bin/sh
#
# $FreeBSD: ports/www/lighttpd/files/lighttpd.sh.in,v 1.4 2007/03/26 03:31:58 mnag Exp $
#
# PROVIDE: lighttpd
# REQUIRE: %%REQUIRE%%
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable lighttpd:
#
# lighttpd_enable (bool):	Set it to "YES" to enable lighttpd
#				Default is "NO".
# lighttpd_conf (path):		Set full path to config file.
#				Default is "%%PREFIX%%/etc/lighttpd.conf".
#

. %%RC_SUBR%%

name="lighttpd"
rcvar=`set_rcvar`

load_rc_config $name

: ${lighttpd_enable="NO"}
: ${lighttpd_conf="%%PREFIX%%/etc/lighttpd.conf"}

command=%%PREFIX%%/sbin/lighttpd
command_args="-f ${lighttpd_conf}"
pidfile=/var/run/lighttpd.pid
required_files=${lighttpd_conf}
stop_postcmd=stop_postcmd
restart_precmd="checkconfig"
reload_precmd=reload_precmd
reload_postcmd=reload_postcmd
sig_reload="-INT"
check_cmd="checkconfig"
extra_commands="reload check"

checkconfig()
{
	echo "Performing sanity check on ${name} configuration:"
	eval "${command} ${command_args} -t"
}

stop_postcmd()
{
	rm -f ${pidfile}
}

reload_precmd()
{
	echo "Stoping ${name} and start gracefully."
}

reload_postcmd()
{
	rm -f ${pidfile}
	run_rc_command start
}

run_rc_command "$1"
