commit e081a5bcf576d47b2383b6e1ddcabd156c3b3af9
Author: Elan Ruusamäe <[email protected]>
Date:   Sun May 3 22:53:46 2015 +0300

    use variables in initscript

 nginx.init | 51 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 21 deletions(-)
---
diff --git a/nginx.init b/nginx.init
index 9ca883e..8cd240e 100755
--- a/nginx.init
+++ b/nginx.init
@@ -3,26 +3,35 @@
 # nginx        Nginx Web Server (@flavor@ version)
 #
 # chkconfig:   345 85 15
-# description: Nginx is a World Wide Web server.  It is used to serve \
-#              HTML files and CGI.
+# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
+#               proxy and IMAP/POP3 proxy server
 # processname: nginx-@flavor@
 # pidfile:     /var/run/nginx-@[email protected]
 # config:      /etc/nginx/nginx-@[email protected]
 
-
 # Source function library
 . /etc/rc.d/init.d/functions
 
-# Get network config
+# Source networking configuration.
 . /etc/sysconfig/network
 
+nginx="/usr/sbin/nginx-@flavor@"
+svname="nginx (@flavor@)"
+prog=${nginx##*/}
+
+sysconfig="/etc/sysconfig/$prog"
+lockfile="/var/lock/subsys/$prog"
+pidfile="/var/run/$prog.pid"
+
+NGINX_CONF_FILE="/etc/nginx/$prog.conf"
+
 # Get service config
-[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
+[ -f $sysconfig ] && . $sysconfig
 
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; 
then
-               msg_network_down nginx-@flavor@
+               msg_network_down "$svname"
                exit 1
        fi
 else
@@ -31,27 +40,27 @@ fi
 
 start() {
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/nginx-@flavor@ ]; then
-               msg_starting nginx-@flavor@
-               daemon /usr/sbin/nginx-@flavor@
+       if [ ! -f $lockfile ]; then
+               msg_starting "$svname"
+               daemon $nginx -c $NGINX_CONF_FILE
                RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nginx-@flavor@
+               [ $RETVAL -eq 0 ] && touch $lockfile
        else
-               msg_already_running nginx-@flavor@
+               msg_already_running "$svname"
        fi
 }
 
 stop() {
        # Stop daemons.
-       if [ -f /var/lock/subsys/nginx-@flavor@ ]; then
-               msg_stopping nginx-@flavor@
-               killproc --waitforname nginx-@flavor@ --waitfortime 60 
nginx-@flavor@
+       if [ -f $lockfile ]; then
+               msg_stopping "$svname"
+               killproc --waitforname $prog --waitfortime 60 $prog
                # Delete pidfile only when nginx was called successfully
                if [ $? -eq 0 ]; then
-                       rm -f /var/lock/subsys/nginx-@flavor@ 
/var/run/nginx-@[email protected] >/dev/null 2>&1
+                       rm -f $lockfile $pidfile >/dev/null 2>&1
                fi
        else
-               msg_not_running nginx-@flavor@
+               msg_not_running "$svname"
        fi
 }
 
@@ -65,7 +74,7 @@ case "$1" in
        stop
        ;;
   status)
-       status nginx-@flavor@
+       status $prog
        RETVAL=$?
        ;;
   restart)
@@ -73,12 +82,12 @@ case "$1" in
        start
        ;;
   reload|force-reload|graceful)
-       if [ -f /var/lock/subsys/nginx-@flavor@ ]; then
-               msg_reloading nginx-@flavor@
-               killproc nginx-@flavor@ -HUP
+       if [ -f $lockfile ]; then
+               msg_reloading "$svname"
+               killproc $prog -HUP
                RETVAL=$?
        else
-               msg_not_running nginx-@flavor@
+               msg_not_running "$svname"
                RETVAL=7
        fi
        ;;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nginx.git/commitdiff/e081a5bcf576d47b2383b6e1ddcabd156c3b3af9

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to