#!/bin/sh
# $FreeBSD: ports/www/nginx-devel/files/nginx.sh.in,v 1.3 2007/06/18 07:13:27 osa Exp $

# PROVIDE: nginx
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Define these nginx_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/nginx
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
nginx_enable=${nginx_enable-"NO"}
nginx_flags=${nginx_flags-""}
nginx_pidfile=${nginx_pidfile-"/var/run/nginx.pid"}

. /etc/rc.subr

name="nginx"
rcvar=`set_rcvar`
command="/usr/local/sbin/nginx"

load_rc_config $name

pidfile="${nginx_pidfile}"

extra_commands="configtest reload"

configtest_cmd="configtest_cmd"
configtest_cmd()  {
	echo "Configuration syntax test for ${name}."
	if ${command} ${nginx_flags} -t; then
		:
	else
		err 8 "FATAL: bad config for ${name}"
	fi
}

start_cmd="echo \"Starting ${name}.\"; /usr/bin/limits -U www ${command} ${nginx_flags}"

run_rc_command "$1"
