Browse Source

Reworked the Let's Encrypt renew functionality to skip removed aliases.
This commit resolves #856.

Raphael Schneeberger 5 years ago
parent
commit
1b6ff8226f
2 changed files with 22 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 21 0
      bin/v-update-letsencrypt-ssl

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
 - Fixed an issue where malformed JSON output was returned when custom theme files are present. (#967)
 - Fixed an error that would occur when running `v-change-user-php-cli` for the first time if .bash_aliases did not exist. (#960)
 - Corrected an issue where tooltips were not displayed when hovering over the top level menu items.
+- Reworked the Let's Encrypt renew functionality to skip removed aliases.
  
 ## [1.2.1] - Service Release
 ### Features

+ 21 - 0
bin/v-update-letsencrypt-ssl

@@ -58,6 +58,27 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
             aliases=$(echo "$aliases" |tr ' ' '\n' |sed "/^$/d")
             aliases=$(echo "$aliases" |egrep -v "^$domain,?$")
             aliases=$(echo "$aliases" |sed -e ':a;N;$!ba;s/\n/,/g')
+
+            # Source domain.conf
+            source <(cat $HESTIA/data/users/$user/web.conf | grep "DOMAIN='$domain'")
+
+            # Split aliases into array
+            IFS=',' read -r -a ALIASES <<< "$ALIAS"
+
+            # Loop trough all crt aliases
+            for alias in ${aliases//,/ } ; do
+                # Validate if the alias still exists in web.conf
+                if [[ " ${ALIASES[@]} " =~ " ${alias} " ]]; then
+                    f_aliases+="$alias,"
+                fi
+            done
+
+            # Remove leading comma
+            if [[ ${f_aliases: -1} = ',' ]] ; then f_aliases=${f_aliases::-1}; fi
+
+            # Write the filtered alias list to the default var
+            aliases=$f_aliases
+
             msg=$($BIN/v-add-letsencrypt-domain $user $domain $aliases)
             if [ $? -ne 0 ]; then
                 log_event $E_INVALID "$domain $msg"