Browse Source

Merge pull request #1780 from jaapmarcus/fix/1767-web-alias-limit-broken

Fix Limit issue Alias
Kristan Kenney 4 years ago
parent
commit
7884d505d5
3 changed files with 17 additions and 6 deletions
  1. 6 1
      bin/v-add-web-domain
  2. 2 3
      bin/v-add-web-domain-alias
  3. 9 2
      func/main.sh

+ 6 - 1
bin/v-add-web-domain

@@ -52,7 +52,12 @@ check_args '2' "$#" 'USER DOMAIN [IP] [RESTART] [ALIASES] [PROXY_EXTENSIONS]'
 is_format_valid 'user' 'domain' 'aliases' 'ip' 'proxy_ext'
 is_format_valid 'user' 'domain' 'aliases' 'ip' 'proxy_ext'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
-is_package_full 'WEB_DOMAINS' 'WEB_ALIASES'
+is_package_full 'WEB_DOMAINS' 
+
+if [ "$aliases" != "none" ]; then 
+    ALIAS=$aliases
+    is_package_full 'WEB_ALIASES' 
+fi
 
 
 if [ "$($BIN/v-list-web-domain $user $domain_utf plain |cut -f 1) " != "$domain" ]; then
 if [ "$($BIN/v-list-web-domain $user $domain_utf plain |cut -f 1) " != "$domain" ]; then
     is_domain_new 'web' "$domain_utf,$aliases"
     is_domain_new 'web' "$domain_utf,$aliases"

+ 2 - 3
bin/v-add-web-domain-alias

@@ -53,8 +53,6 @@ is_object_unsuspended 'user' 'USER' "$user"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
 is_domain_new 'web' "$aliases"
 is_domain_new 'web' "$aliases"
-is_package_full 'WEB_ALIASES'
-
 is_base_domain_owner "$aliases"
 is_base_domain_owner "$aliases"
 
 
 # Perform verification if read-only mode is enabled
 # Perform verification if read-only mode is enabled
@@ -65,7 +63,6 @@ check_hestia_demo_mode
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Parsing domain values
 get_domain_values 'web'
 get_domain_values 'web'
 
 
 # Preparing domain values for the template substitution
 # Preparing domain values for the template substitution
@@ -77,6 +74,8 @@ else
 fi
 fi
 prepare_web_domain_values
 prepare_web_domain_values
 
 
+is_package_full 'WEB_ALIASES'
+
 # Rebuilding vhost
 # Rebuilding vhost
 del_web_config "$WEB_SYSTEM" "$TPL.tpl"
 del_web_config "$WEB_SYSTEM" "$TPL.tpl"
 add_web_config "$WEB_SYSTEM" "$TPL.tpl"
 add_web_config "$WEB_SYSTEM" "$TPL.tpl"

+ 9 - 2
func/main.sh

@@ -179,8 +179,15 @@ is_package_full() {
     esac
     esac
     used=$(echo "$used"| cut -f 1 -d \ )
     used=$(echo "$used"| cut -f 1 -d \ )
     limit=$(grep "^$1=" $USER_DATA/user.conf |cut -f 2 -d \')
     limit=$(grep "^$1=" $USER_DATA/user.conf |cut -f 2 -d \')
-    if [ "$limit" != 'unlimited' ] && [[ "$used" -ge "$limit" ]]; then
-        check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
+    if [ "$1" = WEB_ALIASES ]; then
+        # Used is always calculated with the new alias added
+        if [ "$limit" != 'unlimited' ] && [[ "$used" -gt "$limit" ]]; then
+            check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
+        fi
+    else
+        if [ "$limit" != 'unlimited' ] && [[ "$used" -ge "$limit" ]]; then
+            check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
+        fi
     fi
     fi
 }
 }