Fix handling in apache config if apache version is 2.2

This commit is contained in:
ckubu 2017-02-17 11:41:56 +01:00
parent 928aaa5c37
commit 70352ca7f6

View File

@ -237,6 +237,7 @@ if [[ "$WEBSERVER_INSTALLATION" = "Apache2_Debian" ]] ;then
APACHE_VHOST_DIR=/etc/apache2/sites-enabled APACHE_VHOST_DIR=/etc/apache2/sites-enabled
APACHE_CONF_DIR=/etc/apache2/conf-available APACHE_CONF_DIR=/etc/apache2/conf-available
_set_apache_conf_symlink=true _set_apache_conf_symlink=true
apache_control_script=`which apachectl`
apache_installed=true apache_installed=true
elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then
@ -278,6 +279,7 @@ elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then
APACHE_CONF_DIR=$APACHE_VHOST_DIR APACHE_CONF_DIR=$APACHE_VHOST_DIR
fi fi
apache_control_script=`which apachectl`
apache_installed=true apache_installed=true
elif [[ "$WEBSERVER_INSTALLATION" = "Nginx_Debian" ]] ;then elif [[ "$WEBSERVER_INSTALLATION" = "Nginx_Debian" ]] ;then
@ -347,24 +349,61 @@ _date=`date +%Y-%m-%d-%H%M`
## - Configure Apache.. ## - Configure Apache..
## - ## -
apache_config_changed=false
if [[ -n "$APACHE_CONF_DIR" ]]; then if [[ -n "$APACHE_CONF_DIR" ]]; then
_apache_dh_conf_file=${APACHE_CONF_DIR}/000-dehydrated.conf _apache_dh_conf_file=${APACHE_CONF_DIR}/000-dehydrated.conf
echononl " Configure Apache Webserver: Create alias for WLLKNOWN Directory.." echononl " Configure Apache Webserver: Create alias for WELL-KNOWN Directory.."
cat << EOF > $_apache_dh_conf_file if [[ -f "$_apache_dh_conf_file" ]] ; then
Alias /.well-known/acme-challenge ${DH_WELL_KNOWN_DIR}/ echo_skipped
else
if [[ -x "$apache_control_script" ]] && $apache_control_script -M 2> /dev/null | grep -q version_module > /dev/null 2>&1 ; then
cat << EOF > $_apache_dh_conf_file
Alias /.well-known/acme-challenge /var/www/dehydrated/
<Directory /var/www/dehydrated/> <Directory /var/www/dehydrated/>
Options +FollowSymLinks Options +FollowSymLinks
AllowOverride None AllowOverride None
Require all granted <IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
Satisfy Any
</IfVersion>
</Directory> </Directory>
EOF EOF
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
else else
echo_failed echo_failed
fi
else
cat << EOF > $_apache_dh_conf_file
Alias /.well-known/acme-challenge ${DH_WELL_KNOWN_DIR}/
# - Notice:
# - If apache version < 2.4 (i.e. 2.2.x), then repclace lines
# - 'Require all granted' and 'Satisfy Any' with:
# - Order allow,deny
# - Allow from all
# -
<Directory /var/www/dehydrated/>
Options +FollowSymLinks
AllowOverride None
Require all granted
Satisfy Any
</Directory>
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
fi
apache_config_changed=true
fi fi
if $_set_apache_conf_symlink ; then if $_set_apache_conf_symlink ; then
@ -375,6 +414,7 @@ EOF
ln -s ../conf-available/000-dehydrated.conf /etc/apache2/conf-enabled/000-dehydrated.conf ln -s ../conf-available/000-dehydrated.conf /etc/apache2/conf-enabled/000-dehydrated.conf
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
apache_config_changed=true
else else
echo_failed echo_failed
fi fi
@ -555,17 +595,21 @@ fi
if $apache_installed ; then if $apache_installed ; then
apache_control_script=`which apachectl` apache_control_script=`which apachectl`
echononl " Restarting (graceful) apache webserver.." echononl " Restarting (graceful) apache webserver.."
if [[ -x "$apache_control_script" ]]; then if $apache_config_changed ; then
$apache_control_script graceful if [[ -x "$apache_control_script" ]]; then
if [[ $? -eq 0 ]] ; then $apache_control_script graceful
echo_ok if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
warn "Graceful restart of apache webserver failed.."
fi
else else
echo_failed echo_skipped
warn "Graceful restart of apache webserver failed.." warn "Apache Control Script (apachectl) not found."
fi fi
else else
echo_skipped echo_skipped
warn "Apache Control Script (apachectl) not found."
fi fi
fi fi