diff --git a/install_dehydrated.sh b/install_dehydrated.sh index 32bfa9d..bb5ed1e 100755 --- a/install_dehydrated.sh +++ b/install_dehydrated.sh @@ -237,6 +237,7 @@ if [[ "$WEBSERVER_INSTALLATION" = "Apache2_Debian" ]] ;then APACHE_VHOST_DIR=/etc/apache2/sites-enabled APACHE_CONF_DIR=/etc/apache2/conf-available _set_apache_conf_symlink=true + apache_control_script=`which apachectl` apache_installed=true elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then @@ -278,6 +279,7 @@ elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then APACHE_CONF_DIR=$APACHE_VHOST_DIR fi + apache_control_script=`which apachectl` apache_installed=true elif [[ "$WEBSERVER_INSTALLATION" = "Nginx_Debian" ]] ;then @@ -347,24 +349,61 @@ _date=`date +%Y-%m-%d-%H%M` ## - Configure Apache.. ## - +apache_config_changed=false if [[ -n "$APACHE_CONF_DIR" ]]; then _apache_dh_conf_file=${APACHE_CONF_DIR}/000-dehydrated.conf - echononl " Configure Apache Webserver: Create alias for WLLKNOWN Directory.." - cat << EOF > $_apache_dh_conf_file -Alias /.well-known/acme-challenge ${DH_WELL_KNOWN_DIR}/ + echononl " Configure Apache Webserver: Create alias for WELL-KNOWN Directory.." + if [[ -f "$_apache_dh_conf_file" ]] ; then + 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/ Options +FollowSymLinks AllowOverride None - Require all granted + + Order allow,deny + Allow from all + + = 2.4> + Require all granted + Satisfy Any + EOF - if [[ $? -eq 0 ]] ; then - echo_ok - else - echo_failed + if [[ $? -eq 0 ]] ; then + echo_ok + else + 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 +# - + + Options +FollowSymLinks + AllowOverride None + Require all granted + Satisfy Any + +EOF + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + fi + fi + apache_config_changed=true fi 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 if [[ $? -eq 0 ]] ; then echo_ok + apache_config_changed=true else echo_failed fi @@ -555,17 +595,21 @@ fi if $apache_installed ; then apache_control_script=`which apachectl` echononl " Restarting (graceful) apache webserver.." - if [[ -x "$apache_control_script" ]]; then - $apache_control_script graceful - if [[ $? -eq 0 ]] ; then - echo_ok + if $apache_config_changed ; then + if [[ -x "$apache_control_script" ]]; then + $apache_control_script graceful + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + warn "Graceful restart of apache webserver failed.." + fi else - echo_failed - warn "Graceful restart of apache webserver failed.." + echo_skipped + warn "Apache Control Script (apachectl) not found." fi else echo_skipped - warn "Apache Control Script (apachectl) not found." fi fi