Hi,

I'am using a Maildir++ based quota setting which creates a maildirsize file in 
every Maildir. The first two lines of this file are the maximum quota in bytes 
then the actual consumption in bytes and number of messages, like so : 


1073741824S
379317999 5169



This means this user has a quota of 1Gb and he is using ~ 379 Mb (you have to 
divide by 1024 to be more precise)

Since the script receieves the user as second argument, you can deduce it's 
current quota size and restriction by reading the maildirsize file (if you have 
it). I think you can do the same if your quota is in the database (querying).


This a piece of script I wrote once that shows the value of quota used and 
quota max (both in megas and perecent) that might help you if you know your way 
through bash scripting : 


root@messagerie[10.10.10.19] ~/SCRIPTS/MAIL # cat showquota.single

mega=$((1024*1024))
inbox="${1%@*}"
maildir="/var/vmail/domain.tld/$inbox"
backup="/var/vmail/backup.domain.tld/$inbox"
[ ! -e $maildir ] && echo "Boite email inexistante. Veuillez vérifier encore 
une fois l'orthogrape de $in...@domain.tld" && exit 1
function get_quota {
mailfolder="$1"
maildirsize="$mailfolder/maildirsize" 
fields=$(echo $(head -2 $maildirsize))
max="${fields%%S*}"
cur="$(echo $fields | cut -f2 -d ' ')"
ratio=$(echo "scale=2; $cur * 100 / $max" | bc)
cur=$(echo "scale=2; $cur / $mega" | bc)
max=$(echo "scale=2; $max / $mega" | bc)
echo "$cur Mo /  $max Mo ( $ratio% )"
}
echo Quota sur la boite aux lettres "$inbox"
get_quota "$maildir"
echo Quota sur les archives
get_quota "$backup"
echo "-------------------------------------------------------------------------"
root@messagerie[10.10.10.19] ~/SCRIPTS/MAIL # 



  --Yassine.

Reply via email to