From 1b1851997887df3d321f52474c3768c224d0d406 Mon Sep 17 00:00:00 2001 From: dpeca Date: Fri, 23 Aug 2019 16:11:54 +0200 Subject: [PATCH] Auto-generating LE SSL for hostname --- install/vst-install-debian.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh index 2d6affd3..7f0c51f9 100644 --- a/install/vst-install-debian.sh +++ b/install/vst-install-debian.sh @@ -1482,17 +1482,39 @@ if [ "$release" -eq 10 ]; then service php7.3-fpm restart fi +# Comparing hostname and ip +make_ssl=0 +host_ip=$(host $servername | head -n 1 | awk '{print $NF}') +if [ "$host_ip" = "$ip" ]; then + ip="$servername" + make_ssl=1 +fi + +# Generating LE SSL +www_host="www.$servername" +www_host_ip=$(host $www_host | head -n 1 | awk '{print $NF}') +if [ "$www_host_ip" != "$ip" ]; then + echo "=== Deleting www to server hostname" + v-delete-web-domain-alias 'admin' "$servername" "$www_host" 'no' + v-delete-dns-on-web-alias 'admin' "$servername" "$www_host" 'no' + www_host="" +fi + +echo "Hostname $servername is pointing to $host_ip" + +if [ $make_ssl -eq 1 ]; then + echo "=== Generating HOSTNAME SSL" + v-add-letsencrypt-domain 'admin' "$servername" "$www_host" 'yes' + v-update-host-certificate 'admin' "$servername" +else + echo "=== We will not generate SSL because of this" +fi +echo "UPDATE_HOSTNAME_SSL='yes'" >> /usr/local/vesta/conf/vesta.conf #----------------------------------------------------------# # Vesta Access Info # #----------------------------------------------------------# -# Comparing hostname and ip -host_ip=$(host $servername| head -n 1 | awk '{print $NF}') -if [ "$host_ip" = "$ip" ]; then - ip="$servername" -fi - # Sending notification to admin email echo -e "Congratulations, you have just successfully installed \ Vesta Control Panel