Add support for (debian based) nginx webserver

This commit is contained in:
root 2016-12-04 22:51:23 +01:00
parent 8caf2cc8be
commit 16bbaae997

View File

@ -187,13 +187,15 @@ echo ""
echo ""
echo "[1] Apache2 from Debian Package System"
echo "[2] Apache2 installed from Sources"
echo "[3] Other Webserver Installation"
echo "[3] nginx from Debian Package System"
echo "[4] Other Webserver Installation"
echo ""
echononl "Eingabe: "
while [ "$WEBSERVER_INSTALLATION" != "Apache2_Debian" \
-a "$WEBSERVER_INSTALLATION" != "Apache2_Source" \
-a "$WEBSERVER_INSTALLATION" != "Nginx_Debian" \
-a "$WEBSERVER_INSTALLATION" != "Other_Webserver_Installation" ];do
read OPTION
case $OPTION in
@ -201,10 +203,12 @@ while [ "$WEBSERVER_INSTALLATION" != "Apache2_Debian" \
;;
2) WEBSERVER_INSTALLATION="Apache2_Source"
;;
3) WEBSERVER_INSTALLATION="Other_Webserver_Installation"
3) WEBSERVER_INSTALLATION="Nginx_Debian"
;;
4) WEBSERVER_INSTALLATION="Other_Webserver_Installation"
;;
*) echo ""
echo -e "\tFalsche Eingabe ! [ 1 = Apache2 Debian ; 2 = Apache2 Sources ; 3 = Other ]"
echo -e "\tFalsche Eingabe ! [ 1 = Apache2 Debian ; 2 = Apache2 Sources ; 3 = Nginx Debian ; 4 = Other ]"
echo ""
echononl "Eingabe:"
;;
@ -212,11 +216,14 @@ while [ "$WEBSERVER_INSTALLATION" != "Apache2_Debian" \
done
_set_apache_conf_symlink=false
apache_installed=false
nginx_installed=false
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_installed=true
elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then
@ -257,9 +264,18 @@ elif [[ "$WEBSERVER_INSTALLATION" = "Apache2_Source" ]] ;then
APACHE_CONF_DIR=$APACHE_VHOST_DIR
fi
apache_installed=true
elif [[ "$WEBSERVER_INSTALLATION" = "Nginx_Debian" ]] ;then
NGINX_BASE_DIR=/etc/nginx
NGINX_VHOST_DIR=${NGINX_BASE_DIR}/sites-enabled
NGINX_SNIPPET_DIR=${NGINX_BASE_DIR}/snippets
nginx_installed=true
else
APACHE_VHOST_DIR=
APACHE_CONF_DIR=
NGINX_BASE_DIR=
NGINX_VHOST_DIR=
warn "This Type of Webserver Installation is not yet available"
fi
@ -285,11 +301,16 @@ else
echo -e "DH Cronjob Type...............: \033[33mSkip activation\033[m"
fi
echo ""
if [[ "$APACHE_CONF_DIR" != "$APACHE_VHOST_DIR" ]]; then
echo "Apache Config Directory.......: $APACHE_CONF_DIR"
if [[ "$WEBSERVER_INSTALLATION" =~ Apache2 ]]; then
if [[ "$APACHE_CONF_DIR" != "$APACHE_VHOST_DIR" ]]; then
echo "Apache Config Directory.......: $APACHE_CONF_DIR"
fi
echo "Apache Vhost Directory........: $APACHE_VHOST_DIR"
echo ""
elif [[ "$WEBSERVER_INSTALLATION" =~ Nginx ]]; then
echo "nginx Directory.,............: $NGINX_BASE_DIR"
echo "nginx Vhost Directory........: $NGINX_VHOST_DIR"
fi
echo "Apache Vhost Directory........: $APACHE_VHOST_DIR"
echo ""
echononl "Start with that configuration? [yes/no]: "
read OK
@ -312,7 +333,7 @@ if [[ -n "$APACHE_CONF_DIR" ]]; then
_apache_dh_conf_file=${APACHE_CONF_DIR}/000-dehydrated.conf
echononl " Configure Apache Webserver: Create alias foe WLLKNOWN Directory.."
echononl " Configure Apache Webserver: Create alias for WLLKNOWN Directory.."
cat << EOF > $_apache_dh_conf_file
Alias /.well-known/acme-challenge ${DH_WELL_KNOWN_DIR}/
@ -343,6 +364,43 @@ EOF
fi
fi
if [[ -n "$NGINX_BASE_DIR" ]]; then
if [[ ! -d $NGINX_SNIPPET_DIR ]]; then
echononl " Create ${NGINX_SNIPPET_DIR}.."
mkdir $NGINX_SNIPPET_DIR
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
fi
echononl " Configure Nginx Webserver: Create alias for WLLKNOWN Directory.."
if ! grep grep -E "location\s+/.well-known/acme-challenge/" ${NGINX_SNIPPET_DIR}/letsencrypt-acme-challenge.conf > /dev/null 2>&1 ; then
cat <<EOF > ${NGINX_SNIPPET_DIR}/letsencrypt-acme-challenge.conf
location /.well-known/acme-challenge/ {
alias /var/www/dehydrated/;
location ~ /.well-known/acme-challenge/(.*) {
default_type text/plain;
}
}
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
warn "In your appropriate server definitions (or in the global one is exists) add line:\n\n\t\033[37m\033[1minclude /etc/nginx/snippets/letsencrypt-acme-challenge.conf;\033[m"
else
echo_failed
fi
else
echo_skipped
fi
fi
if [[ -d "$DH_WELL_KNOWN_DIR" ]]; then
echononl " Backup \"$DH_WELL_KNOWN_DIR\" directory.."
mv $DH_WELL_KNOWN_DIR $DH_WELL_KNOWN_DIR.$_date
@ -440,19 +498,35 @@ if [[ -d "${DH_WELL_KNOWN_DIR}.$_date" ]] ; then
fi
apache_control_script=`which apachectl`
echononl " Restarting (graceful) apache webserver.."
if [[ -n "$apache_control_script" ]]; then
$apache_control_script graceful
if $apache_installed ; then
apache_control_script=`which apachectl`
echononl " Restarting (graceful) apache webserver.."
if [[ -n "$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_skipped
warn "Apache Control Script (apachectl) not found."
fi
else
apache_installed=/etc/init.d/apache2
fi
if $nginx_installed ; then
nginx_init_script=/etc/init.d/nginx
echononl " Restarting nginx webserver.."
/etc/init.d/nginx restart > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
warn "Graceful restart of apache webserver failed.."
warn "Restart of nginx webserver failed.."
fi
else
echo_skipped
warn "Apache Control Script (apachectl) not found."
fi
@ -647,7 +721,9 @@ while read -r line || [[ -n "$line" ]]; do
echo " #cp -a \`realpath \$FULLCHAINFILE\` \`realpath \$FULLCHAINFILE\`.ORIG" >> $HOOK_OUT_FILE
echo " #cat \`realpath \$FULLCHAINFILE\`.ORIG \${BASEDIR}/certs/\${DOMAIN}/root-\${TIMESTAMP}.ca > \$FULLCHAINFILE" >> $HOOK_OUT_FILE
echo " cat \$KEYFILE \$FULLCHAINFILE > \${BASEDIR}/certs/\${DOMAIN}/privkey_cert_chain-\${TIMESTAMP}.pem" >> $HOOK_OUT_FILE
echo " rm \${BASEDIR}/certs/\${DOMAIN}/privkey_cert_chain.pem" >> $HOOK_OUT_FILE
echo " if [[ -h \"\${BASEDIR}/certs/\${DOMAIN}/privkey_cert_chain.pem\" ]]; then" >> $HOOK_OUT_FILE
echo " rm \${BASEDIR}/certs/\${DOMAIN}/privkey_cert_chain.pem" >> $HOOK_OUT_FILE
echo " fi" >> $HOOK_OUT_FILE
echo " ln -s privkey_cert_chain-\${TIMESTAMP}.pem \${BASEDIR}/certs/\${DOMAIN}/privkey_cert_chain.pem" >>$HOOK_OUT_FILE
echo " echo \" + Hook: \$DOMAIN - Certificate has been produced\"" >> $HOOK_OUT_FILE
echo "" >> $HOOK_OUT_FILE
@ -740,8 +816,8 @@ ftp_server_alt_names=""
postfix_installed=false
dovecot_installed=false
pureftpd_installed=false
apache_installed=true
nginx_installed=false
apache_installed=$apache_installed
nginx_installed=$nginx_installed
# ---
@ -861,8 +937,8 @@ ftp_server_alt_names=""
postfix_installed=false
dovecot_installed=false
pureftpd_installed=false
apache_installed=true
nginx_installed=false
apache_installed=$apache_installed
nginx_installed=$nginx_installed
# ---
@ -1970,6 +2046,7 @@ cat <<EOF > ${DH_BASE_DIR}/tools/create_domains_file.sh
_DH_BASE_DIR=$DH_BASE_DIR
_APACHE_VHOST_DIR=$APACHE_VHOST_DIR
_NGINX_VHOST_DIR=$NGINX_VHOST_DIR
# -------------
@ -2064,14 +2141,24 @@ DOMAINS_TXT_FILE=\${DH_BASE_DIR}/domains.txt
if [[ ! -d "\$_APACHE_VHOST_DIR" ]]; then
if [[ -d "/etc/apache2/sites-available" ]]; then
_APACHE_VHOST_DIR=/etc/apache2/conf-available
_VHOST_DIR=/etc/apache2/conf-available
elif [[ -d "/usr/local/apache2/conf/vhosts" ]]; then
if [[ -d "/usr/local/apache2/conf/vhosts/0" ]]; then
_APACHE_VHOST_DIR=/usr/local/apache2/conf/vhosts/0
_VHOST_DIR=/usr/local/apache2/conf/vhosts/0
else
_APACHE_VHOST_DIR=/usr/local/apache2/conf/vhosts
_VHOST_DIR=/usr/local/apache2/conf/vhosts
fi
fi
else
_VHOST_DIR=\$_APACHE_VHOST_DIR
fi
if [[ ! -d "\$_NGINX_VHOST_DIR" ]]; then
if [[ -d "/etc/nginx/sites-available" ]]; then
_VHOST_DIR=\$_NGINX_VHOST_DIR
fi
else
_VHOST_DIR=\$_NGINX_VHOST_DIR
fi
echo ""
@ -2080,16 +2167,16 @@ echo ""
echo "Insert VHost Directory"
echo ""
echo ""
APACHE_VHOST_DIR=
while [[ "X\$APACHE_VHOST_DIR" = "X" ]]; do
echononl "VHost Directory [\$_APACHE_VHOST_DIR]: "
read APACHE_VHOST_DIR
if [ "X\$APACHE_VHOST_DIR" = "Xnone" -o "X\$APACHE_VHOST_DIR" = "XNone" ]; then
VHOST_DIR=
while [[ "X\$VHOST_DIR" = "X" ]]; do
echononl "VHost Directory [\$_VHOST_DIR]: "
read VHOST_DIR
if [ "X\$VHOST_DIR" = "Xnone" -o "X\$VHOST_DIR" = "XNone" ]; then
warn "Webserver Configuration will be ommited"
APACHE_VHOST_DIR=
VHOST_DIR=
break
elif [[ "X\$APACHE_VHOST_DIR" = "X" ]]; then
APACHE_VHOST_DIR=\$_APACHE_VHOST_DIR
elif [[ "X\$VHOST_DIR" = "X" ]]; then
VHOST_DIR=\$_VHOST_DIR
fi
done
@ -2159,7 +2246,7 @@ echononl " Create Array of VHost configuration files.."
while IFS='' read -r -d '' filename ; do
if [[ \`basename \$filename\` =~ ^00 ]] ; then
continue
elif ! grep SSLCertificate \$filename > /dev/null 2>&1 ; then
elif ! grep SSLCertificate \$filename > /dev/null 2>&1 && ! grep ssl_certificate \$filename > /dev/null 2>&1; then
continue
# - Internationalized domain names (starting with xn--) not yet supported
@ -2168,6 +2255,8 @@ while IFS='' read -r -d '' filename ; do
continue
elif grep -e "^\s*ServerAlias.*xn--" \$filename > /dev/null 2>&1 ; then
continue
elif grep -e "^\s*server_name.*xn--" \$filename > /dev/null 2>&1 ; then
continue
elif containsElement \`basename \${filename%.*}\` \${SITE_WITHOUT_CERTS_arr[@]} ; then
continue
@ -2175,7 +2264,7 @@ while IFS='' read -r -d '' filename ; do
vhost_file_arr+=("\`realpath \$filename\`")
fi
done < <(find \$APACHE_VHOST_DIR -mindepth 1 -maxdepth 1 -name "*.conf" -print0)
done < <(find \$VHOST_DIR -mindepth 1 -maxdepth 1 -name "*.conf" -print0)
if [[ \$? -eq 0 ]]; then
echo_ok
else
@ -2195,12 +2284,13 @@ for file in \${vhost_file_arr[@]} ; do
_server_alias=""
number_errors=0
more_aliases=false
echo ""
echononl " Get ServerName/ServerAlias from file \"\`basename \$file\`\""
while read line ; do
# - Get ServerName
# - Get ServerName Apache
if echo \$line | grep -e "^\s*ServerName" > /dev/null ; then
_server_name_tmp=\`echo \$line | awk '{print\$2}'\`
if [ -z "\$_server_name" ]; then
@ -2216,6 +2306,51 @@ for file in \${vhost_file_arr[@]} ; do
continue
fi
# - Get Server Names (also Aliases) Nginx
if echo \$line | grep -e "^\s*server_name" > /dev/null ; then
_server_name_tmp=\`echo \$line | sed -e "s/server_name//" | sed "s/;//" | sed "s/^\s*//" | sed "s/\s*$//"\`
if [[ -z "\$_server_name_tmp" ]] ; then
if [ \$number_errors -eq 0 ]; then
echo "[ Error ]: Misconfigured ServerName in file \"\$file\""
fi
_server_name_failed=true
let number_errors++
continue
fi
_server_name=\`echo \$_server_name_tmp | awk '{print\$1}'\`
_server_alias_tmp=\${_server_name_tmp#\$_server_name}
for _alias in \$_server_alias_tmp ; do
containsElement "\$_alias" "\${_server_aliases_arr[@]}" && continue
_server_aliases_arr+=("\$_alias")
done
if ! echo \$line | grep ";" > /dev/null 2>&1 ; then
more_aliases=true
continue
else
more_aliases=false
fi
fi
if \$more_aliases ; then
_server_aliases_tmp=\`echo \$line | sed "s/;//" | sed "s/^\s*//" | sed "s/\s*$//"\`
for _alias in \$_server_aliases_tmp ; do
containsElement "\$_alias" "\${_server_aliases_arr[@]}" && continue
_server_aliases_arr+=("\$_alias")
done
if echo \$line | grep ";" > /dev/null 2>&1 ; then
more_aliases=false
else
continue
fi
fi
containsElement \$_server_name \${SITE_WITHOUT_CERTS_arr[@]} && continue
# - Get ServerAlias
@ -2242,8 +2377,19 @@ for file in \${vhost_file_arr[@]} ; do
echo_done
fi
add_to_domains=false
echononl " Add Servernames to \"\$DOMAINS_TXT_FILE\".."
if ! grep -e "^\$_server_name" \$DOMAINS_TXT_FILE > /dev/null 2>&1 ; then
add_to_domains=true
else
for _alias in \${_server_aliases_arr[@]} ; do
if ! grep -e "^\$_server_name.*\$_alias" \$DOMAINS_TXT_FILE > /dev/null 2>&1 ; then
sed -i "/^\$_server_name/d" \$DOMAINS_TXT_FILE
add_to_domains=true
fi
done
fi
if \$add_to_domains ; then
echo "\$_server_name \${_server_aliases_arr[@]}" >> \$DOMAINS_TXT_FILE
if [[ \$? -eq 0 ]] ; then
echo_ok
@ -2339,6 +2485,7 @@ cat <<EOF > ${DH_BASE_DIR}/tools/change_ssl_directives.sh
_DH_BASE_DIR=$DH_BASE_DIR
_APACHE_VHOST_DIR=$APACHE_VHOST_DIR
_NGINX_VHOST_DIR=$NGINX_VHOST_DIR
_apache_debian_install=false
@ -2439,17 +2586,25 @@ fi
if [[ ! -d "\$_APACHE_VHOST_DIR" ]]; then
if [[ -d "/etc/apache2/sites-available" ]]; then
_APACHE_VHOST_DIR=/etc/apache2/conf-available
_VHOST_DIR=/etc/apache2/conf-available
elif [[ -d "/usr/local/apache2/conf/vhosts" ]]; then
if [[ -d "/usr/local/apache2/conf/vhosts/0" ]]; then
_APACHE_VHOST_DIR=/usr/local/apache2/conf/vhosts/0
_VHOST_DIR=/usr/local/apache2/conf/vhosts/0
else
_APACHE_VHOST_DIR=/usr/local/apache2/conf/vhosts
_VHOST_DIR=/usr/local/apache2/conf/vhosts
fi
fi
else
_VHOST_DIR=\$_APACHE_VHOST_DIR
fi
echo ""
if [[ ! -d "\$_NGINX_VHOST_DIR" ]]; then
if [[ -d "/etc/nginx/sites-available" ]]; then
_VHOST_DIR=\$_NGINX_VHOST_DIR
fi
else
_VHOST_DIR=\$_NGINX_VHOST_DIR
fi
echo ""
echo -e "\033[32m--\033[m"
@ -2457,21 +2612,22 @@ echo ""
echo "Insert VHost Directory"
echo ""
echo ""
APACHE_VHOST_DIR=
while [[ "X\$APACHE_VHOST_DIR" = "X" ]]; do
echononl "VHost Directory [\$_APACHE_VHOST_DIR]: "
read APACHE_VHOST_DIR
if [ "X\$APACHE_VHOST_DIR" = "Xnone" -o "X\$APACHE_VHOST_DIR" = "XNone" ]; then
VHOST_DIR=
while [[ "X\$VHOST_DIR" = "X" ]]; do
echononl "VHost Directory [\$_VHOST_DIR]: "
read VHOST_DIR
if [ "X\$VHOST_DIR" = "Xnone" -o "X\$VHOST_DIR" = "XNone" ]; then
warn "Webserver Configuration will be ommited"
APACHE_VHOST_DIR=
VHOST_DIR=
break
elif [[ "X\$APACHE_VHOST_DIR" = "X" ]]; then
APACHE_VHOST_DIR=\$_APACHE_VHOST_DIR
elif [[ "X\$VHOST_DIR" = "X" ]]; then
VHOST_DIR=\$_VHOST_DIR
fi
done
if [[ ! -d "\$APACHE_VHOST_DIR" ]]; then
fatal "No Apaqche VHost Configuration directory found!"
if [[ ! -d "\$VHOST_DIR" ]]; then
fatal "No Webserver VHost Configuration directory found!"
fi
echo ""
@ -2486,7 +2642,7 @@ echo "DH domains.txt file...........: \$DOMAINS_TXT_FILE"
echo ""
echo "Script Installation Directory.: \${DH_BASE_DIR}/tools"
echo ""
echo "Vhosts Directory..............: \$APACHE_VHOST_DIR"
echo "Vhosts Directory..............: \$VHOST_DIR"
echo ""
echononl "Start with that configuration? [yes/no]: "
@ -2500,12 +2656,19 @@ done
_date=\`date +%Y-%m-%d-%H%M\`
if [[ "\$APACHE_VHOST_DIR" = "/etc/apache2/sites-enabled" ]] ; then
if [[ "\$VHOST_DIR" = "/etc/apache2/sites-enabled" ]] ; then
APACHE_VHOST_DIR="/etc/apache2/sites-available"
VHOST_DIR=\$APACHE_VHOST_DIR
fi
echononl " Backup existing VHost Directory.."
cp -a \$APACHE_VHOST_DIR \${APACHE_VHOST_DIR}.\$_date
if [[ "\$VHOST_DIR" = "/etc/nginx/sites-enabled" ]] ; then
NGINX_VHOST_DIR="/etc/nginx/sites-available"
VHOST_DIR=\$NGINX_VHOST_DIR
fi
echo ""
echononl " Backup existing VHost Directory .."
cp -a \$VHOST_DIR \${VHOST_DIR}.\$_date
if [[ \$? -eq 0 ]] ; then
echo_ok
else
@ -2516,14 +2679,25 @@ echo ""
declare -a vhost_file_arr
while IFS=' ' read -r site_server_name rest ; do
unset vhost_file_arr
while IFS=' ' read filename_site ; do
#if ! \$_apache_debian_install ; then
# [[ -h "\$filename_site" ]] && continue
#fi
if ! containsElement \`realpath \$filename_site\` \${vhost_file_arr[@]} ; then
vhost_file_arr+=("\`realpath \$filename_site\`")
fi
done < <(grep -s -l -E "ServerName\s+\${site_server_name}" \${APACHE_VHOST_DIR}/*)
if [[ "\$VHOST_DIR" = "\$APACHE_VHOST_DIR" ]]; then
while IFS=' ' read filename_site ; do
#if ! \$_apache_debian_install ; then
# [[ -h "\$filename_site" ]] && continue
#fi
if ! containsElement \`realpath \$filename_site\` \${vhost_file_arr[@]} ; then
vhost_file_arr+=("\`realpath \$filename_site\`")
fi
done < <(grep -s -l -E "ServerName\s+\${site_server_name}" \${VHOST_DIR}/*)
else
while IFS=' ' read filename_site ; do
#if ! \$_apache_debian_install ; then
# [[ -h "\$filename_site" ]] && continue
#fi
if ! containsElement \`realpath \$filename_site\` \${vhost_file_arr[@]} ; then
vhost_file_arr+=("\`realpath \$filename_site\`")
fi
done < <(grep -s -l -E "server_name\s+\${site_server_name}" \${VHOST_DIR}/*)
fi
echononl " Adjust entries for \"\${site_server_name}\" .."
if [[ \${#vhost_file_arr[@]} -eq 0 ]]; then
@ -2542,14 +2716,25 @@ while IFS=' ' read -r site_server_name rest ; do
continue
fi
failed=false
for _name in \${vhost_file_arr[@]} ; do
perl -i -n -p -e s"#^(\s*)SSLCertificateFile.*#\1SSLCertificateFile \${_cert_dir}/fullchain.pem#" \$_name
[[ \$? -ne 0 ]] && failed=true
perl -i -n -p -e s"#^(\s*)SSLCertificateKeyFile.*#\1SSLCertificateKeyFile \${_cert_dir}/privkey.pem#" \$_name
[[ \$? -ne 0 ]] && failed=true
sed -i '/SSLCertificateChainFile/d' \$_name
[[ \$? -ne 0 ]] && failed=true
done
if [[ "\$VHOST_DIR" = "\$APACHE_VHOST_DIR" ]]; then
for _name in \${vhost_file_arr[@]} ; do
perl -i -n -p -e s"#^(\s*)SSLCertificateFile.*#\1SSLCertificateFile \${_cert_dir}/fullchain.pem#" \$_name
[[ \$? -ne 0 ]] && failed=true
perl -i -n -p -e s"#^(\s*)SSLCertificateKeyFile.*#\1SSLCertificateKeyFile \${_cert_dir}/privkey.pem#" \$_name
[[ \$? -ne 0 ]] && failed=true
sed -i '/SSLCertificateChainFile/d' \$_name
[[ \$? -ne 0 ]] && failed=true
done
else
for _name in \${vhost_file_arr[@]} ; do
perl -i -n -p -e s"#^(\s*)ssl_certificate\s+.*#\1ssl_certificate \${_cert_dir}/fullchain.pem;#" \$_name
[[ \$? -ne 0 ]] && failed=true
perl -i -n -p -e s"#^(\s*)ssl_certificate_key\s+.*#\1ssl_certificate_key \${_cert_dir}/privkey.pem;#" \$_name
[[ \$? -ne 0 ]] && failed=true
sed -i '/SSLCertificateChainFile/d' \$_name
[[ \$? -ne 0 ]] && failed=true
done
fi
if \$failed ; then
echo_failed
else
@ -2559,41 +2744,67 @@ while IFS=' ' read -r site_server_name rest ; do
done < <(cat \$DOMAINS_TXT_FILE)
if [[ -d "\${APACHE_VHOST_DIR}.\$_date" ]]; then
diff -Nur \$APACHE_VHOST_DIR \${APACHE_VHOST_DIR}.\$_date > /dev/null 2>&1
if [[ -d "\${VHOST_DIR}.\$_date" ]]; then
diff -Nur \$VHOST_DIR \${VHOST_DIR}.\$_date > /dev/null 2>&1
if [[ \$? -eq 0 ]]; then
info "No VHosts configuration has changed.\n\t Removing previously created backup"
echononl "Delete \"\${APACHE_VHOST_DIR}.\$_date\".."
rm -rf \${APACHE_VHOST_DIR}.\$_date
echononl "Delete \"\${VHOST_DIR}.\$_date\".."
rm -rf \${VHOST_DIR}.\$_date
if [[ \$? -eq 0 ]]; then
echo_ok
else
echo_failed
fi
else
if [[ -x "$apache_control_script" ]]; then
$apache_control_script graceful > /dev/null 2>&1
if [[ \$? -gt 0 ]]; then
if \$verbose ; then
error "Restarting Apache Webserver failed!"
if [[ "\$VHOST_DIR" = "\$APACHE_VHOST_DIR" ]]; then
if [[ -x "$apache_control_script" ]]; then
$apache_control_script graceful > /dev/null 2>&1
if [[ \$? -gt 0 ]]; then
if \$verbose ; then
error "Restarting Apache Webserver failed!"
else
echo -e "\\n [ Error ]: Restarting Apache Webserver failed! \\n"
fi
else
echo -e "\\n [ Error ]: Restarting Apache Webserver failed! \\n"
if \$verbose ; then
info "Apache Webserver restarted."
else
echo -e "\\n [ Info ]: Apache Webserver restarted.\\n"
fi
fi
else
if \$verbose ; then
info "Apache Webserver restarted."
warn "Apache Control Script (apachectl) not found. Take care to restart webservice manually"
else
echo -e "\\n [ Info ]: Apache Webserver restarted.\\n"
echo -e "\\n [ Warn ]: Apache Control Script (apachectl) not found. Take care to restart webservice manually"
fi
fi
else
if \$verbose ; then
warn "Apache Control Script (apachectl) not found. Take care to restart webservice manually"
else
echo -e "\\n [ Warn ]: Apache Control Script (apachectl) not found. Take care to restart webservice manually"
fi
fi
else
if [[ -x "$nginx_init_script" ]]; then
$nginx_init_script restart > /dev/null 2>&1
if [[ \$? -gt 0 ]]; then
if \$verbose ; then
error "Restarting Nginx Webserver failed!"
else
echo -e "\\n [ Error ]: Restarting Nginx Webserver failed! \\n"
fi
else
if \$verbose ; then
info "Nginx Webserver restarted."
else
echo -e "\\n [ Info ]: Nginx Webserver restarted.\\n"
fi
fi
else
if \$verbose ; then
warn "Nginx Init Script ($nginx_init_script) not found. Take care to restart webservice manually"
else
echo -e "\\n [ Warn ]: Nginx INIT Script ($nginx_init_script) not found. Take care to restart webservice manually"
fi
fi
fi
fi
fi