Skip to content

Commit 7efc500

Browse files
committed
Improved code as sugested @Lupul
1 parent 146519a commit 7efc500

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bin/v-add-web-domain-alias

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ format_aliases
4242
#----------------------------------------------------------#
4343

4444
# Parsing domain values as they are used to get the current alias usage
45-
get_domain_values 'web'
45+
4646

4747
if [ -z "$aliases" ]; then
4848
check_result $E_INVALID "invalid alias format: empty"
@@ -56,8 +56,6 @@ is_object_unsuspended 'user' 'USER' "$user"
5656
is_object_valid 'web' 'DOMAIN' "$domain"
5757
is_object_unsuspended 'web' 'DOMAIN' "$domain"
5858
is_domain_new 'web' "$aliases"
59-
is_package_full 'WEB_ALIASES'
60-
6159
is_base_domain_owner "$aliases"
6260

6361
# Perform verification if read-only mode is enabled
@@ -68,6 +66,8 @@ check_hestia_demo_mode
6866
# Action #
6967
#----------------------------------------------------------#
7068

69+
get_domain_values 'web'
70+
7171
# Preparing domain values for the template substitution
7272
local_ip=$(get_real_ip $IP)
7373
if [ -z "$ALIAS" ]; then
@@ -77,6 +77,8 @@ else
7777
fi
7878
prepare_web_domain_values
7979

80+
is_package_full 'WEB_ALIASES'
81+
8082
# Rebuilding vhost
8183
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
8284
add_web_config "$WEB_SYSTEM" "$TPL.tpl"

func/main.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,15 @@ is_package_full() {
179179
esac
180180
used=$(echo "$used"| cut -f 1 -d \ )
181181
limit=$(grep "^$1=" $USER_DATA/user.conf |cut -f 2 -d \')
182-
if [ "$limit" != 'unlimited' ] && [[ "$used" -ge "$limit" ]]; then
183-
check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
182+
if [ "$1" = WEB_ALIASES ]; then
183+
# Used is always calculated with the new alias added
184+
if [ "$limit" != 'unlimited' ] && [[ "$used" -gt "$limit" ]]; then
185+
check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
186+
fi
187+
else
188+
if [ "$limit" != 'unlimited' ] && [[ "$used" -ge "$limit" ]]; then
189+
check_result $E_LIMIT "$1 limit is reached :: upgrade user package"
190+
fi
184191
fi
185192
}
186193

0 commit comments

Comments
 (0)