Skip to content

Commit 7281a4b

Browse files
committed
unlimited quota support
1 parent aaa8419 commit 7281a4b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

bin/v-add-mail-account

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
1616
domain_idn=$(idn -t --quiet -a "$domain")
1717
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
1818
password=$4
19-
quota=${5-0}
19+
quota=${5-unlimited}
2020

2121
# Includes
2222
source $VESTA/func/main.sh
@@ -33,7 +33,10 @@ EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
3333
#----------------------------------------------------------#
3434

3535
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
36-
validate_format 'user' 'domain' 'account' 'quota'
36+
validate_format 'user' 'domain' 'account'
37+
if [ "$quota" != 'unlimited' ]; then
38+
validate_format 'quota'
39+
fi
3740
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
3841
is_object_valid 'user' 'USER' "$user"
3942
is_object_unsuspended 'user' 'USER' "$user"
@@ -54,6 +57,9 @@ md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
5457

5558
# Adding account info into password file
5659
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
60+
if [ "$quota" = 'unlimited' ]; then
61+
quota='0'
62+
fi
5763
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
5864
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
5965
fi
@@ -63,6 +69,10 @@ fi
6369
# Vesta #
6470
#----------------------------------------------------------#
6571

72+
if [[ "$quota" -eq '0' ]]; then
73+
quota='unlimited'
74+
fi
75+
6676
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
6777
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
6878
str="$str DATE='$DATE'"

bin/v-change-mail-account-quota

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ source $VESTA/conf/vesta.conf
2828
#----------------------------------------------------------#
2929

3030
check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
31-
validate_format 'user' 'domain' 'account' 'quota'
31+
validate_format 'user' 'domain' 'account'
32+
if [ "$quota" != 'unlimited' ]; then
33+
validate_format 'quota'
34+
fi
3235
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
3336
is_object_valid 'user' 'USER' "$user"
3437
is_object_unsuspended 'user' 'USER' "$user"
@@ -44,6 +47,9 @@ is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
4447

4548
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
4649
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
50+
if [ "$quota" = 'unlimited' ]; then
51+
quota=0
52+
fi
4753
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
4854
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
4955
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
@@ -54,6 +60,10 @@ fi
5460
# Vesta #
5561
#----------------------------------------------------------#
5662

63+
if [[ "$quota" -eq 0 ]]; then
64+
quota='unlimited'
65+
fi
66+
5767
# Update quota
5868
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
5969

0 commit comments

Comments
 (0)