Script to count quota usage using postfixadmin and maildir (postfix vda)
xoxoxoxoxoxo The script begin here: xoxoxoxoxoxo
echo "updating quota2"
#change to maildir folder
cd /home/vmail/yourdomain.com
#write in one line
du -s * | awk '{ print "insert into quota2 values (\"" $2 "\"," $1 "*1000,1000) on duplicate key update bytes=" $1 "*1000;" }' | mysql -uroot -pyourpassword postfixadmin
echo "done"
xoxoxoxoxoxo end of script xoxoxoxoxoxo
Put the script in crontab, run as often as you wish.
Modify /etc/postfixadmin/config.inc.php:
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';
echo "updating quota2"
#change to maildir folder
cd /home/vmail/yourdomain.com
#write in one line
du -s * | awk '{ print "insert into quota2 values (\"" $2 "\"," $1 "*1000,1000) on duplicate key update bytes=" $1 "*1000;" }' | mysql -uroot -pyourpassword postfixadmin
echo "done"
xoxoxoxoxoxo end of script xoxoxoxoxoxo
Put the script in crontab, run as often as you wish.
Modify /etc/postfixadmin/config.inc.php:
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';
Comments