eg-updater gracefully handles apache not running
authorBill Erickson <berickxx@gmail.com>
Fri, 1 May 2015 16:17:05 +0000 (12:17 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Before, the script would exit because the apache stop command would
return non-zero.

Includes minor wording changes.

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

index 4e24cf6..0705cbe 100755 (executable)
@@ -551,7 +551,7 @@ inspect_params;
 if [ -n "$DETACH_NEEDED" ]; then
 
     if [ ! -f $PING_FILE ]; then
-        announce "No ping file found.  Skipping detach."
+        announce "No ping file found."
 
     else
         announce "Detaching brick"
@@ -583,8 +583,16 @@ elif [ -n "$DETACH_ONLY" ]; then
 elif [ -z "$ATTACH_ONLY" ]; then
 
     if [ -z "$SKIP_APACHE" -a -z "$START_ONLY" ]; then
-        announce "Stopping Apache"
-        sudo service apache2 stop > /dev/null
+        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 "Stopping Apache"
+            sudo service apache2 stop > /dev/null
+        else
+            announce "Apache not running"
+        fi
     fi
 
     # Note the use of --fast-shutdown-all, which is faster than the