From 7281a4b5bbf347579d8c58299bc083323843ec6c Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Fri, 29 May 2015 19:48:34 +0300 Subject: [PATCH] unlimited quota support --- bin/v-add-mail-account | 14 ++++++++++++-- bin/v-change-mail-account-quota | 12 +++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bin/v-add-mail-account b/bin/v-add-mail-account index 892fe9f7..814b5585 100755 --- a/bin/v-add-mail-account +++ b/bin/v-add-mail-account @@ -16,7 +16,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") account=$(echo $3 | tr '[:upper:]' '[:lower:]') password=$4 -quota=${5-0} +quota=${5-unlimited} # Includes 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]' -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_object_valid '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 if [[ "$MAIL_SYSTEM" =~ exim ]]; then + if [ "$quota" = 'unlimited' ]; then + quota='0' + fi str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd fi @@ -63,6 +69,10 @@ fi # Vesta # #----------------------------------------------------------# +if [[ "$quota" -eq '0' ]]; then + quota='unlimited' +fi + str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'" str="$str DATE='$DATE'" diff --git a/bin/v-change-mail-account-quota b/bin/v-change-mail-account-quota index 84a65c26..2c9d3924 100755 --- a/bin/v-change-mail-account-quota +++ b/bin/v-change-mail-account-quota @@ -28,7 +28,10 @@ source $VESTA/conf/vesta.conf #----------------------------------------------------------# 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_object_valid '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') if [[ "$MAIL_SYSTEM" =~ exim ]]; then + if [ "$quota" = 'unlimited' ]; then + quota=0 + fi sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd @@ -54,6 +60,10 @@ fi # Vesta # #----------------------------------------------------------# +if [[ "$quota" -eq 0 ]]; then + quota='unlimited' +fi + # Update quota update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"