check_webservice_load.sh: add support for apache2 systemd service.

This commit is contained in:
Christoph 2017-12-28 11:13:56 +01:00
parent 5bd4f7fef5
commit 50b01f734a

View File

@ -184,13 +184,22 @@ if $check_apache ; then
fi
fi
APACHE_SYSTEMD_SERVICE_EXISTS=false
if $systemd_supported ; then
if $(locate apache2.service > /dev/null 2>&1) ; then
APACHE_SYSTEMD_SERVICE_EXISTS=true
fi
fi
APACHE_INIT_SCRIPT=""
if [ -x "/etc/init.d/apache2" ]; then
APACHE_INIT_SCRIPT="/etc/init.d/apache2"
elif [ -x "/etc/init.d/apachectl" ]; then
APACHE_INIT_SCRIPT="/etc/init.d/apachectl"
else
fatal 'Cannot find init-script for Apache web server!'
fi
if [[ -z "$APACHE_INIT_SCRIPT" ]] && ! $APACHE_SYSTEMD_SERVICE_EXISTS ; then
fatal 'Neither an init-script nor a service file for apache2 found!'
fi
fi
@ -363,7 +372,11 @@ stop_apache() {
## - Stop Apache Webservice
## -
$APACHE_INIT_SCRIPT stop > /dev/null 2>&1
if $APACHE_SYSTEMD_SERVICE_EXISTS ; then
systemctl stop apache2 > /dev/null 2>&1
else
$APACHE_INIT_SCRIPT stop > /dev/null 2>&1
fi
sleep 12
@ -691,7 +704,14 @@ start_apache() {
send_msg=$1
send_msg=${send_msg:=true}
$APACHE_INIT_SCRIPT start > /dev/null 2>&1
## - Start Apache Webservice
## -
if $APACHE_SYSTEMD_SERVICE_EXISTS ; then
systemctl start apache2 > /dev/null 2>&1
else
$APACHE_INIT_SCRIPT start > /dev/null 2>&1
fi
sleep 2
NEWPID=$(ps aux | grep "$HTTPD" | grep -v grep | grep root | awk '{print$2}')