aboutsummaryrefslogtreecommitdiffstats
path: root/community/nginx-naxsi/nginx.initd
diff options
context:
space:
mode:
Diffstat (limited to 'community/nginx-naxsi/nginx.initd')
-rw-r--r--community/nginx-naxsi/nginx.initd42
1 files changed, 42 insertions, 0 deletions
diff --git a/community/nginx-naxsi/nginx.initd b/community/nginx-naxsi/nginx.initd
new file mode 100644
index 0000000000..bec20dddaa
--- /dev/null
+++ b/community/nginx-naxsi/nginx.initd
@@ -0,0 +1,42 @@
+#!/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"
+}