]> git.pld-linux.org Git - packages/apache.git/blobdiff - apache1.init
- enhance mod_ldap description
[packages/apache.git] / apache1.init
index 55f0f3eac778e6fb3967776c6b18b90bf2c35ee9..8ea17174cd7a51ab20d54104fff4ff56acda9f43 100644 (file)
@@ -22,7 +22,6 @@
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-               # nls "ERROR: Networking is down. %s can't be run." <service>
                msg_network_down apache
                exit 1
        fi
@@ -34,10 +33,12 @@ if is_no "${IPV6_NETWORKING}"; then
        HTTPD_OPTS="$HTTPD_OPTS -4"
 fi
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+configtest() {
+       apache -t > /dev/null 2>&1
+       RETVAL=$?
+}
+
+start() {
        # Check if the service is already running?
        if [ -x /usr/lib/apache1/lingerd ]; then
                if [ ! -f /var/lock/subsys/lingerd ]; then
@@ -57,8 +58,9 @@ case "$1" in
        else
                msg_already_running apache
        fi
-       ;;
-  stop)
+}
+
+stop() {
        # Stop daemons.
        if [ -f /var/lock/subsys/apache ]; then
                msg_stopping apache
@@ -76,65 +78,77 @@ case "$1" in
                        msg_not_running lingerd
                fi
        fi
-       ;;
-  status)
-       status apache
-       RETVAL=$?
-       /usr/sbin/apache -S
-       ;;
-  restart)
-       apache -t > /dev/null 2>&1
-       RETVAL=$?
+}
+
+restart() {
+       configtest
        if [ $RETVAL -eq 0 ]; then
-               $0 stop
-               RETVAL=$((RETVAL + $?))
-               $0 start
-               RETVAL=$((RETVAL + $?))
+               stop
+               start
        else
                fail
-               echo "Configuration file syntax test failed."
+               echo >&2 "Configuration file syntax test failed."
        fi
+}
 
-       ;;
-  reload|force-reload)
-       if [ -f /var/lock/subsys/apache ]; then
+reload() {
+       sig=${1:-HUP}
+       retnr=${2:-7}
+       if [ -f /var/lock/subsys/apache ]; then
                msg_reloading apache
 
-               apache -t > /dev/null 2>&1
-               RETVAL=$?
+               configtest
                if [ $RETVAL -eq 0 ]; then
-                       killproc apache -HUP
+                       killproc apache -$sig
+                       RETVAL=$?
                else
                        fail
-                       echo "Configuration file syntax test failed."
+                       echo >&2 "Configuration file syntax test failed."
                fi
        else
-               msg_not_running apache >&2
-               RETVAL=7
+               msg_not_running apache
+               RETVAL=$retnr
        fi
-       ;;
-  graceful)
-       if [ -f /var/lock/subsys/apache ]; then
-               msg_reloading apache
+}
 
-               apache -t > /dev/null 2>&1
-               RETVAL=$?
-               if [ $RETVAL -eq 0 ]; then
-                       killproc apache -USR1
-               else
-                       fail
-                       echo "Configuration file syntax test failed."
-               fi
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  status)
+       status apache
+       RETVAL=$?
+       /usr/sbin/apache -S
+       ;;
+  restart)
+       restart
+       ;;
+  try-restart)
+       if [ -f /var/lock/subsys/apache ]; then
+               restart
        else
-               msg_not_running apache >&2
-               RETVAL=7
+               msg_not_running apache
        fi
        ;;
+  force-reload)
+       reload HUP 7
+       ;;
+  reload|graceful)
+       reload USR1 7
+       ;;
+  flush-logs)
+       reload USR1 0
+       ;;
   configtest)
        apache -t
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
        exit 3
        ;;
 esac
This page took 0.031467 seconds and 4 git commands to generate.