Improve detection of apache systemd service file if exists.
This commit is contained in:
parent
569cde854e
commit
00fcb8de66
@ -214,21 +214,45 @@ if $check_apache ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APACHE_SYSTEMD_SERVICE_EXISTS=false
|
|
||||||
if $systemd_supported ; then
|
if $systemd_supported ; then
|
||||||
if $(locate apache2.service > /dev/null 2>&1) ; then
|
# - Is Service exclusive controlled by systemd
|
||||||
APACHE_SYSTEMD_SERVICE_EXISTS=true
|
# -
|
||||||
|
if systemctl -t service list-unit-files \
|
||||||
|
| grep -e "^mysql" \
|
||||||
|
| grep -q enabled 2> /devnull ; then
|
||||||
|
|
||||||
|
MYSQLD_SERVICE_FILE=$(systemctl -t service list-unit-files \
|
||||||
|
| grep -e "^mysql" \
|
||||||
|
| awk '{print$1}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
APACHE_SERVICE_FILE=""
|
||||||
|
APACHE_INIT_SCRIPT=""
|
||||||
|
if $systemd_supported ; then
|
||||||
|
# - Is Service exclusive controlled by systemd
|
||||||
|
# -
|
||||||
|
if systemctl -t service list-unit-files \
|
||||||
|
| grep -e "^apache" \
|
||||||
|
| grep -q enabled 2> /devnull ; then
|
||||||
|
|
||||||
|
APACHE_SERVICE_FILE=$(systemctl -t service list-unit-files \
|
||||||
|
| grep -e "^apache" \
|
||||||
|
| awk '{print$1}')
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APACHE_INIT_SCRIPT=""
|
if [[ -z "$APACHE_SERVICE_FILE" ]] ; then
|
||||||
if [ -x "/etc/init.d/apache2" ]; then
|
if [ -x "/etc/init.d/apache2" ]; then
|
||||||
APACHE_INIT_SCRIPT="/etc/init.d/apache2"
|
APACHE_INIT_SCRIPT="/etc/init.d/apache2"
|
||||||
elif [ -x "/etc/init.d/apachectl" ]; then
|
elif [ -x "/etc/init.d/apachectl" ]; then
|
||||||
APACHE_INIT_SCRIPT="/etc/init.d/apachectl"
|
APACHE_INIT_SCRIPT="/etc/init.d/apachectl"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$APACHE_INIT_SCRIPT" ]] && ! $APACHE_SYSTEMD_SERVICE_EXISTS ; then
|
if [[ -z "$APACHE_INIT_SCRIPT" ]] && [[ -z "$APACHE_SERVICE_FILE" ; then
|
||||||
fatal 'Neither an init-script nor a service file for apache2 found!'
|
fatal 'Neither an init-script nor a service file for apache2 found!'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -402,8 +426,8 @@ stop_apache() {
|
|||||||
|
|
||||||
## - Stop Apache Webservice
|
## - Stop Apache Webservice
|
||||||
## -
|
## -
|
||||||
if $APACHE_SYSTEMD_SERVICE_EXISTS ; then
|
if [[ -n "$APACHE_SERVICE_FILE" ]] ; then
|
||||||
systemctl stop apache2 > /dev/null 2>&1
|
systemctl stop "$APACHE_SERVICE_FILE" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
$APACHE_INIT_SCRIPT stop > /dev/null 2>&1
|
$APACHE_INIT_SCRIPT stop > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
@ -705,8 +729,8 @@ start_apache() {
|
|||||||
|
|
||||||
## - Start Apache Webservice
|
## - Start Apache Webservice
|
||||||
## -
|
## -
|
||||||
if $APACHE_SYSTEMD_SERVICE_EXISTS ; then
|
if [[ -n "$APACHE_SERVICE_FILE" ]] ; then
|
||||||
systemctl start apache2 > /dev/null 2>&1
|
systemctl start "$APACHE_SERVICE_FILE" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
$APACHE_INIT_SCRIPT start > /dev/null 2>&1
|
$APACHE_INIT_SCRIPT start > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user