Change default vhost configuration. Add killing remaining httpd-pids if stopping apache2 was not successfully.

This commit is contained in:
Christoph 2018-01-02 01:00:21 +01:00
parent 87506fe9df
commit 6f70737c93

View File

@ -1632,35 +1632,37 @@ if $START_AT_BOOTTIME && $APACHE_WEBSERVICE_RUNNING ; then
error "Stopping Apache Webservice failed!"
fi
PIDS="$(ps aux | grep -E "(bin/apache2 |bin/httpd )" | grep -v grep | awk '{print$2}')"
declare -i i=0
# # - Does NOT wor - don't know why
# # -
# declare -i i=0
# if [[ -n "$_httpd_binary" ]] ; then
#
# sleep 5
#
# PIDS="$(ps aux | grep "$(realpath "$_httpd_binary")" | grep -v grep | awk '{print$2}')"
#
# while [[ "X$PIDS" != "X" ]]; do
#
# if [[ $i -eq 0 ]]; then
# warn "Stopping Apache Webservice failed. Going to kill remaining httpd-processes.."
# fi
#
# if [[ $i -gt 10 ]]; then
# error "Killing remaining httpd-processes failed !"
# break
# fi
#
# for _PID in $PIDS ; do
# kill -9 $_PID > /dev/null 2>&1
# done
# sleep 2
# PIDS="$(ps aux | grep "$(realpath "$_httpd_binary")" | grep -v grep | awk '{print$2}')"
# i=i+1
# done
# fi
while [[ -n "${PIDS}" ]]; do
if [[ $i -eq 0 ]]; then
warn "Stopping Apache Webservice failed."
echononl "\tGoing to kill remaining httpd-processes .."
echo "" >> ${_logdir}/main.log
echo "## - Going to kill remaining httpd-processes" >> ${_logdir}/main.log
echo "## -" >> ${_logdir}/main.log
fi
if [[ $i -gt 10 ]]; then
echo_failed
erro "Killing remaining httpd-processes failed !"
break
fi
sleep 2
for _PID in $PIDS ; do
echo "kill -9 $_PID" >> ${_logdir}/main.log
kill -9 $_PID >> ${_logdir}/main.log 2>&1
done
PIDS="$(ps aux | grep -E "(bin/apache2 |bin/httpd )" | grep -v grep | awk '{print$2}')"
(( i++ ))
[[ $i -le 10 ]] && echo_ok
done
else
echo_skipped
@ -3494,22 +3496,10 @@ cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
</VirtualHost>
# -- dummy.${_DOMAIN}.$_TLD -- #
EOF
if $SEPARATE_LISTEN_DIRECTIVES ; then
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
<VirtualHost ${IPv4_FIRST}:80>
EOF
else
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
<VirtualHost *:80>
EOF
fi
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
ServerName dummy.${_DOMAIN}.$_TLD
RewriteEngine On
@ -3524,19 +3514,8 @@ cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
ErrorLog /var/log/apache2/dummy.${_DOMAIN}.${_TLD}.error
</VirtualHost>
EOF
if $SEPARATE_LISTEN_DIRECTIVES ; then
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
<VirtualHost ${IPv4_FIRST}:443>
EOF
else
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
<VirtualHost *:443>
EOF
fi
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
ServerName dummy.${_DOMAIN}.$_TLD
DocumentRoot "$GLOBAL_DOC_ROOT"
@ -3557,17 +3536,35 @@ cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
</VirtualHost>
EOF
if [[ -n "$IPv6_FIRST" ]] && $SEPARATE_LISTEN_DIRECTIVES ; then
_default_ipv4=false
_default_ipv6=false
if [[ -n "${IPv4_FIRST}" ]]; then
_default_ipv4=true
fi
if [[ -n "${IPv6_FIRST}" ]]; then
_default_ipv6=true
fi
_vhost_default_80=""
_vhost_default_443=""
if $_default_ipv4 && $_default_ipv6 ; then
_vhost_default_80="<VirtualHost ${IPv4_FIRST} [${IPv6_FIRST}]:80>"
_vhost_default_443="<VirtualHost ${IPv4_FIRST} [${IPv6_FIRST}]:443>"
elif $_default_ipv4 ; then
_vhost_default_80="<VirtualHost ${IPv4_FIRST}:80>"
_vhost_default_443="<VirtualHost ${IPv4_FIRST}:443>"
elif $_default_ipv6 ; then
_vhost_default_80="<VirtualHost [${IPv6_FIRST}]:80>"
_vhost_default_443="<VirtualHost [${IPv6_FIRST}]:443>"
fi
if $_default_ipv4 || $_default_ipv6 ; then
cat <<EOF >> ${PREFIX}/conf/vhosts/00default.conf
## -
## - IPv6
## -
# -- dummy.oopen.de -- #
<VirtualHost [${IPv6_FIRST}]:80>
$_vhost_default_80
ServerName dummy.${_DOMAIN}.$_TLD
@ -3583,7 +3580,7 @@ if [[ -n "$IPv6_FIRST" ]] && $SEPARATE_LISTEN_DIRECTIVES ; then
ErrorLog /var/log/apache2/dummy.${_DOMAIN}.${_TLD}.error
</VirtualHost>
<VirtualHost [${IPv6_FIRST}]:443>
$_vhost_default_443
ServerName dummy.${_DOMAIN}.$_TLD
@ -3606,6 +3603,7 @@ if [[ -n "$IPv6_FIRST" ]] && $SEPARATE_LISTEN_DIRECTIVES ; then
EOF
fi
if [ -d "${PREFIX}/conf/vhosts/0" ] ; then
echo "" >> ${PREFIX}/conf/vhosts/00default.conf
echo "Include conf/vhosts/0/*.conf" >> ${PREFIX}/conf/vhosts/00default.conf