blob: 9e723d5b732298629357a0915c5a297fd574829a [file] [log] [blame] [raw]
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx-naxsi-ui
# Required-Start: $local_fs $remote_fs $network $syslog nginx
# Required-Stop: $local_fs $remote_fs $network $syslog nginx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx-naxsi-ui using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_intercept=/usr/sbin/naxsi-ui-intercept
DAEMON_extract=/usr/sbin/naxsi-ui-extract
NAME=nginx-naxsi-ui
NAME_intercept=nginx-naxsi-ui_intercept
NAME_extract=nginx-naxsi-ui_extract
DESC=nginx-naxsi-ui
# Include nginx defaults if available
if [ -f /etc/default/nginx-naxsi-ui ]; then
. /etc/default/nginx-naxsi-ui
fi
test -x $DAEMON_intercept || exit 0
test -x $DAEMON_extract || exit 0
set -e
. /lib/lsb/init-functions
case "$1" in
start)
echo -n "Starting $DESC: "
# Check if the ULIMIT is set in /etc/default/nginx
if [ -n "$ULIMIT" ]; then
# Set the ulimits
ulimit $ULIMIT
fi
start-stop-daemon --start --quiet --pidfile /run/$NAME_intercept.pid \
--exec /usr/bin/daemon -- $DAEMON_intercept || true
echo "$NAME_intercept."
start-stop-daemon --start --quiet --pidfile /run/$NAME_extract.pid \
--exec /usr/bin/daemon -- $DAEMON_extract || true
echo "$NAME_extract."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /run/$NAME_extract.pid && rm /run/$NAME_extract.pid || true
echo "$NAME_extract."
start-stop-daemon --stop --quiet --pidfile /run/$NAME_intercept.pid && rm /run/$NAME_intercept.pid || true
echo "$NAME_intercept."
;;
restart|force-reload|reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile /run/$NAME_extract.pid && rm /run/$NAME_extract.pid || true
echo "$NAME_extract."
start-stop-daemon --stop --quiet --pidfile /run/$NAME_intercept.pid && rm /run/$NAME_intercept.pid || true
echo "$NAME_intercept."
sleep 1
start-stop-daemon --start --quiet --pidfile /run/$NAME_intercept.pid \
--exec /usr/bin/daemon -- $DAEMON_intercept || true
echo "$NAME_intercept."
start-stop-daemon --start --quiet --pidfile /run/$NAME_extract.pid \
--exec /usr/bin/daemon -- $DAEMON_extract || true
echo "$NAME_extract."
;;
status)
(status_of_proc -p /run/$NAME_extract.pid "$DAEMON_extract" nginx-naxsi-ui_extract && status_of_proc -p /run/$NAME_intercept.pid "$DAEMON_intercept" nginx-naxsi-ui_intercept) && exit 0 || exit $?
;;
*)
echo "Usage: $NAME {start|stop|restart|reload|force-reload|status}" >&2
exit 1
;;
esac
exit 0