Maildroprc Automatically Delete quotawarn File in Maildir

This is the Ugly workaround

Postfix master.cf setting

maildrop  unix  -       n       n       -       -       pipe
  flags=ODRhu user=vmail argv=/usr/bin/maildrop -w 90 -d ${recipient} ${user} ${domain}

With this setting maildrop wil warn user if their Maildir reach 90% of quota and send warning to user

The problem is, even if user emptying their maildir, users wil always get warning because quotawarn is still in Maildir

[vchkpw] quotawarn question

#
MAILHOME="/var/data/postfix"
DOMAIN="$2"
USER="$1"

QUOTA=`echo "$MAILDIRQUOTA" | cut -f 1 -d S`
USAGE=`du -sb "$MAILHOME/$DOMAIN/$USER/" | awk '{print $1}'`
PERCENT=`echo "$QUOTA * 90/100" | bc`

if ( "$USAGE" < "$PERCENT" )
{
        `/bin/rm -f "$MAILHOME/$DOMAIN/$USER/quotawarn"`
}

That mean, when user deleting some files in their Mailidr, maildroprc will recalculate user’s Maildir usage

QUOTA=`echo "$MAILDIRQUOTA" | cut -f 1 -d S`

This will obtain user quota

USAGE=`du -sb "$MAILHOME/$DOMAIN/$USER/" | awk '{print $1}'`

This wil resulting summary of user’s Maildir Disk Usage in byte

PERCENT=`echo "$QUOTA * 90/100" | bc`

This wil calculate 90% of user’s real quota

if ( "$USAGE" < "$PERCENT" )
{
        `/bin/rm -f "$MAILHOME/$DOMAIN/$USER/quotawarn"`
}

When $USAGE is lower than 90% of user’s quota:

`/bin/rm -f "$MAILHOME/$DOMAIN/$USER/quotawarn"`

Will be executed

This is work in my system, or am i missing something about quotawarn file?

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *