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"
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