aboutsummaryrefslogblamecommitdiffstats
path: root/community/nginx-naxsi/nginx.initd
blob: bec20dddaaa8561b23ba7451262613518aba39c8 (plain) (tree)
1
                  








































                                                                             
#!/sbin/openrc-run

extra_started_commands="reload"
extra_commands="configtest"

depend() {
	need net
	use dns logger netmount
}

CONFFILE=${CONFFILE:-/etc/nginx/${SVCNAME}.conf}
PIDFILE=${PIDFILE:-/var/run/${SVCNAME}.pid}

configtest() {
	ebegin "Checking ${SVCNAME} configuration"
	mkdir -p /tmp/nginx
	/usr/sbin/nginx -c ${CONFFILE} -t
	eend $? "failed, please correct errors above"
}

start() {
	configtest || return 1
	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --start --pidfile "${PIDFILE}" \
		--exec /usr/sbin/nginx -- -c ${CONFFILE} -g "pid ${PIDFILE};"
	eend $? "Failed to start ${SVCNAME}"
}

stop() {
	configtest || return 1
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --pidfile "${PIDFILE}"
	eend $? "Failed to stop ${SVCNAME}"
	rm -f "${PIDFILE}"
}

reload() {
	configtest || return 1
	ebegin "Refreshing ${SVCNAME} configuration"
	kill -HUP $(cat "${PIDFILE}") &>/dev/null
	eend $? "Failed to reload nginx"
}