eg-updater.sh: Apache control repairs/additions
authorBill Erickson <berickxx@gmail.com>
Tue, 24 May 2016 15:36:36 +0000 (11:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
1. If apache is already running when start-apache is called, stop it
first.  This is useful when calling start-apache (or start-all) directly
after a reboot, where Apache may have started automatically at boot.

2. Force a call to 'detach' when stop-apache is called directly as a
safety measure.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/admin-scripts/eg-updater.sh

index 774ab50..eee5413 100755 (executable)
@@ -180,6 +180,10 @@ function inspect_params {
         ACTIONS="$ACTIONS,detach,stop-apache,stop-eg";
     fi
 
+    if [[ "$ACTIONS" =~ "stop-apache" ]]; then
+        ACTIONS="$ACTIONS,detach";
+    fi
+
     if [[ "$ACTIONS" =~ "deploy-all" ]]; then
         ACTIONS="$ACTIONS,update-eg,deploy-eg";
     fi
@@ -662,6 +666,15 @@ if [[ "$ACTIONS" =~ "start-eg" ]]; then
 fi
 
 if [[ "$ACTIONS" =~ "start-apache" ]]; then
+    set +e # temporarily disable exit-on-error setting
+    service apache2 status 2>&1 > /dev/null
+    stat=$?
+    set -e
+    if [ $stat -eq 0 ]; then # apache running
+        announce "Apache is already running.  Stopping first..."
+        sudo service apache2 stop > /dev/null
+        sleep 3;
+    fi
     announce "Starting Apache"
     sudo service apache2 start > /dev/null
 fi