Anton Reutov пре 4 година
родитељ
комит
4feb62c4c8
1 измењених фајлова са 52 додато и 1 уклоњено
  1. 52 1
      install/vst-install-debian.sh

+ 52 - 1
install/vst-install-debian.sh

@@ -1394,9 +1394,60 @@ echo "NOTIFY_ADMIN_FULL_BACKUP='$email'" >> $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Comparing hostname and ip
 # Comparing hostname and ip
-host_ip=$(host $servername| head -n 1 | awk '{print $NF}')
+
+if [ "$ssl" = 'no' ]; then
+host_ip=$(host $servername |head -n 1 |awk '{print $NF}')
+if [ "$host_ip" = "$ip" ]; then
+    ip="$servername"
+fi
+fi
+
+if [ "$ssl" = 'yes' ]; then
+make_ssl=0
+host_ip=$(host $servername | head -n 1 | awk '{print $NF}')
+if [ "$host_ip" != "$pub_ip" ]; then
+    echo "***** PROBLEM: Hostname $servername is not pointing to your server (IP address $ip)"
+    echo "Without pointing your hostname to your IP, LetsEncrypt SSL will not be generated for your server hostname."
+    echo "Try to setup an A record in your DNS, pointing your hostname $servername to IP address $ip and then press ENTER."
+    echo "(or register ns1.$servername and ns2.$servername as DNS Nameservers and put those Nameservers on $servername domain)"
+    echo "If we detect that hostname is still not pointing to your IP, installer will not add LetsEncrypt SSL certificate to your hosting panel (unsigned SSL will be used instead)."
+    read -p "To force to try anyway to add LetsEncrypt, press f and then ENTER." answer
+    host_ip=$(host $servername | head -n 1 | awk '{print $NF}')
+fi
+if [ "$answer" = "f" ]; then
+    make_ssl=1
+fi
 if [ "$host_ip" = "$ip" ]; then
 if [ "$host_ip" = "$ip" ]; then
     ip="$servername"
     ip="$servername"
+    make_ssl=1
+fi
+
+if [ $make_ssl -eq 1 ]; then
+    # Check if www is also pointing to our IP
+    www_host="www.$servername"
+    www_host_ip=$(host $www_host | head -n 1 | awk '{print $NF}')
+    if [ "$www_host_ip" != "$pub_ip" ]; then
+        if [ "$named" = 'yes' ]; then
+            echo "=== Deleting www to server hostname"
+            $VESTA/bin/v-delete-web-domain-alias 'admin' "$servername" "$www_host" 'no'
+            $VESTA/bin/v-delete-dns-on-web-alias 'admin' "$servername" "$www_host" 'no'
+        fi
+        www_host=""
+   fi
+fi
+
+echo "==="
+echo "Hostname $servername is pointing to $host_ip"
+
+if [ $make_ssl -eq 1 ]; then
+    echo "=== Generating HOSTNAME SSL"
+    $VESTA/bin/v-add-letsencrypt-domain 'admin' "$servername" "$www_host" 'yes'
+    $VESTA/bin/v-update-host-certificate 'admin' "$servername"
+else
+    echo "We will not generate SSL because of this"
+fi
+echo "==="
+echo "UPDATE_HOSTNAME_SSL='yes'" >> $VESTA/conf/vesta.conf
 fi
 fi
 
 
 # Sending notification to admin email
 # Sending notification to admin email