summaryrefslogtreecommitdiff
path: root/network/nginx/rc.nginx
diff options
context:
space:
mode:
authorCherife Li <cherife@dotimes.com>2010-05-11 20:01:39 +0200
committerRobby Workman <rworkman@slackbuilds.org>2010-05-11 20:01:39 +0200
commiteae603ee41cf522828c07a4e8c490f4522d97800 (patch)
treefe7c4daa36f9d3cf9f5e87f2e9388e483eed7ab9 /network/nginx/rc.nginx
parent574b4d8305ea176e481f7ef5e4baa565df6ecc99 (diff)
downloadslackbuilds-eae603ee41cf522828c07a4e8c490f4522d97800.tar.gz
network/nginx: Added to 12.0 repository
Diffstat (limited to 'network/nginx/rc.nginx')
-rw-r--r--network/nginx/rc.nginx90
1 files changed, 90 insertions, 0 deletions
diff --git a/network/nginx/rc.nginx b/network/nginx/rc.nginx
new file mode 100644
index 0000000000..5483458425
--- /dev/null
+++ b/network/nginx/rc.nginx
@@ -0,0 +1,90 @@
+#!/bin/sh
+#
+# Nginx daemon control script.
+#
+# This is an init script for the nginx daemon.
+# To use nginx, you must first set up the config file(s).
+#
+# Written for Slackware Linux by Cherife Li <cherife@dotimes.com>.
+#
+
+DAEMON=/usr/sbin/nginx
+CONF=/etc/nginx/nginx.conf
+PID=/var/run/nginx.pid
+
+nginx_start() {
+ # Sanity checks.
+ if [ ! -r $CONF ]; then # no config file, exit:
+ echo "Please check the nginx config file, exiting..."
+ exit 1
+ fi
+
+ if [ -f $PID ]; then
+ echo "Nging is already running?"
+ exit 1
+ fi
+
+ echo "Starting Nginx server daemon:"
+ if [ -x $DAEMON ]; then
+ $DAEMON -c $CONF
+ fi
+}
+
+nginx_test_conf() {
+ echo -e "Checking configuration for correct syntax and\nthen trying to open files referenced in configuration..."
+ $DAEMON -t -c $CONF
+}
+
+nginx_term() {
+ echo "Shutdown Nginx quickly..."
+ kill -TERM $(cat $PID)
+}
+
+nginx_quit() {
+ echo "Shutdown Nginx gracefully..."
+ kill -QUIT $(cat $PID)
+}
+
+nginx_reload() {
+ echo "Reloading Nginx configuration..."
+ kill -HUP $(cat $PID)
+}
+
+nginx_upgrade() {
+ echo -e "Upgrading to the new Nginx binary.\nMake sure the Nginx binary has been replaced with new one\nor Nginx server modules were added/removed."
+ kill -USR2 $(cat $PID)
+ sleep 3
+ kill -QUIT $(cat $PID.oldbin)
+}
+
+nginx_restart() {
+ nginx_quit
+ sleep 5
+ nginx_start
+}
+
+case "$1" in
+'start')
+ nginx_start
+ ;;
+'term')
+ nginx_term
+ ;;
+'quit')
+ nginx_quit
+ ;;
+'stop')
+ nginx_quit
+ ;;
+'reload')
+ nginx_reload
+ ;;
+'restart')
+ nginx_restart
+ ;;
+'upgrade')
+ nginx_upgrade
+ ;;
+*)
+ echo "usage $0 start|term|quit(stop)|reload|restart|upgrade"
+esac