Browse Source

Improve SSL certificate check during rebuild

Kristan Kenney 7 years ago
parent
commit
4513c3a305
1 changed files with 9 additions and 11 deletions
  1. 9 11
      func/rebuild.sh

+ 9 - 11
func/rebuild.sh

@@ -498,17 +498,6 @@ rebuild_mail_domain_conf() {
         if [ ! -z "$CATCHALL" ]; then
             echo "*@$domain_idn:$CATCHALL" >> $dom_aliases
         fi
-
-        # Remove and recreate SSL configuration
-        if [ "$SSL" = 'yes' ]; then
-            del_mail_ssl_config
-            add_mail_ssl_config
-
-            # Update counters
-            update_object_value 'mail' 'DOMAIN' "$domain" '$SSL' "yes"
-            U_MAIL_SSL=$((U_MAIL_SSL + 1))
-        fi
-
     fi
 
     # Rebuild domain accounts
@@ -560,6 +549,15 @@ rebuild_mail_domain_conf() {
         chown $user:mail $HOMEDIR/$user/mail/$domain_idn
     fi
 
+    # Remove and recreate SSL configuration
+    if [ -f "$HOMEDIR/$user/conf/mail/$domain/ssl/$domain.crt" ]; then
+        del_mail_ssl_config
+        add_mail_ssl_config
+        update_object_value 'mail' 'DOMAIN' "$domain" '$SSL' "yes"
+    else
+        update_object_value 'mail' 'DOMAIN' "$domain" '$SSL' "no"
+    fi
+
     dom_disk=0
     for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
         home_dir=$HOMEDIR/$user/mail/$domain/$account