mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 13:01:52 -07:00
unlimited quota support
This commit is contained in:
parent
aaa841964e
commit
7281a4b5bb
2 changed files with 23 additions and 3 deletions
|
@ -16,7 +16,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
|
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
|
||||||
password=$4
|
password=$4
|
||||||
quota=${5-0}
|
quota=${5-unlimited}
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -33,7 +33,10 @@ EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
|
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
|
||||||
validate_format 'user' 'domain' 'account' 'quota'
|
validate_format 'user' 'domain' 'account'
|
||||||
|
if [ "$quota" != 'unlimited' ]; then
|
||||||
|
validate_format 'quota'
|
||||||
|
fi
|
||||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -54,6 +57,9 @@ md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
|
||||||
|
|
||||||
# Adding account info into password file
|
# Adding account info into password file
|
||||||
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
|
if [ "$quota" = 'unlimited' ]; then
|
||||||
|
quota='0'
|
||||||
|
fi
|
||||||
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
||||||
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
fi
|
fi
|
||||||
|
@ -63,6 +69,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [[ "$quota" -eq '0' ]]; then
|
||||||
|
quota='unlimited'
|
||||||
|
fi
|
||||||
|
|
||||||
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
|
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
|
||||||
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
|
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
|
||||||
str="$str DATE='$DATE'"
|
str="$str DATE='$DATE'"
|
||||||
|
|
|
@ -28,7 +28,10 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
|
check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
|
||||||
validate_format 'user' 'domain' 'account' 'quota'
|
validate_format 'user' 'domain' 'account'
|
||||||
|
if [ "$quota" != 'unlimited' ]; then
|
||||||
|
validate_format 'quota'
|
||||||
|
fi
|
||||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -44,6 +47,9 @@ is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
||||||
|
|
||||||
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
|
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
|
||||||
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
|
if [ "$quota" = 'unlimited' ]; then
|
||||||
|
quota=0
|
||||||
|
fi
|
||||||
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
||||||
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
|
@ -54,6 +60,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [[ "$quota" -eq 0 ]]; then
|
||||||
|
quota='unlimited'
|
||||||
|
fi
|
||||||
|
|
||||||
# Update quota
|
# Update quota
|
||||||
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
|
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue