mailbox quota again and again

Discussion in 'Installation/Configuration' started by jmroth, Sep 1, 2008.

  1. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    Hi there,
    when using the standard quota script (quota.rc.master) I'm getting in my logs:

    Code:
    Command output: ==================== QUOTA:     10000000000 INBOXSIZE: web8_admin Bouncing (inbox already full!) )
    
    Suffice to say, no mails are delivered like that.
    I guess INBOXSIZE should be a number and not the username. So I believe something is wrongly parsed there.

    I'm not that fluent in procmail language so if someone could maybe comment the quota.rc.master file? ;)

    Anyway I'm posting my quota.rc which I have always used and which is working fine (for me).
    Code:
    #!/bin/bash
    
    QUOTA=10000000000 #10GB
    
    GROUP_QUOTA_ENABLED=0
    quota -wg | grep -q ": none" || GROUP_QUOTA_ENABLED=1
    if [ $GROUP_QUOTA_ENABLED -eq 1 ]; then
            FS_GROUP_QUOTA=`quota -wg | tail -1 | awk '{print $3}'`*1024
            FS_GROUP_QUOTA=$(($FS_GROUP_QUOTA))
            FS_GROUP_QUOTA_USED=`quota -wg | tail -1 | awk '{print $2}' | sed -n 's/
    ^\([0-9]*\).*$/\1/g p'`*1024
            FS_GROUP_QUOTA_USED=$(($FS_GROUP_QUOTA_USED))
            FS_GROUP_QUOTA_FREE=$(($FS_GROUP_QUOTA-$FS_GROUP_QUOTA_USED))
    else
            FS_GROUP_QUOTA=0
    fi
    
    USER_QUOTA_ENABLED=0
    quota -wu | grep -q ": none" || USER_QUOTA_ENABLED=1
    if [ $USER_QUOTA_ENABLED -eq 1 ]; then
            FS_USER_QUOTA=`quota -wu | tail -1 | awk '{print $3}'`*1024
            FS_USER_QUOTA=$(($FS_USER_QUOTA))
            FS_USER_QUOTA_USED=`quota -wu | tail -1 | awk '{print $2}' | sed -n 's/^
    \([0-9]*\).*$/\1/g p'`*1024
            FS_USER_QUOTA_USED=$(($FS_USER_QUOTA_USED))
            FS_USER_QUOTA_FREE=$(($FS_USER_QUOTA-$FS_USER_QUOTA_USED))
    else
            FS_USER_QUOTA=0
    fi
    
    if [ $FS_USER_QUOTA == 0 ]; then
            if [ $FS_GROUP_QUOTA != 0 ]; then
            # we have unlimtied user filesystem quota but the group is limited
                    if [ $FS_GROUP_QUOTA_FREE -lt $QUOTA ]; then
                            QUOTA=$FS_GROUP_QUOTA_FREE
                    else
                            QUOTA=$QUOTA
                    fi
            else
            # unlimited user and group quota
                    QUOTA=$QUOTA
            fi
    else
            # both quotas are enabled
            # the minimum of user and group quotas counts
            if [ $FS_GROUP_QUOTA != 0 ]; then
                    if [ $FS_USER_QUOTA_FREE -lt $FS_GROUP_QUOTA_FREE ]; then
                            QUOTA=$FS_USER_QUOTA_FREE
                    else
                            QUOTA=$FS_GROUP_QUOTA_FREE
                    fi
            # user quota is enabled and group quota is disabled
            else
                    if [ $FS_USER_QUOTA_FREE -gt 0 ]; then
                            QUOTA=$FS_USER_QUOTA_FREE
                    else
                            QUOTA=0
                    fi
            fi
    fi
    
    echo $QUOTA
    
    EDIT Actually, I am calling the above code from quota.rc like so:
    Code:
    # quota.rc by Stuart Clark/Falko Timme
    #
    # If mailbox size exceeds QUOTA, send reply email
    # using $PMDIR/bounce-exceed-quota.txt
    ##
    # If incoming message size exceeds available storage
    # space (user/group filesystem quota) then
    # send reply email using bounce-exceed-quota.txt
    #
    #LOGFILE="/tmp/procmail.quota.$LOGNAME.log"
    #VERBOSE=YES
    DROPPRIVS=YES
    
    ## using repquota will not work because normal users must not use it
    PATH="/usr/bin:$PATH:/usr/local/bin"
    SHELL=/bin/sh
    EMAIL=`formail -zxTo:`
    
    QUOTA=`iipmailquotacheck.sh`
    :0
    * > ${QUOTA}
    {
            LOG="*** The disk space of this user or domain has been exceeded. Please
     try again at a later time. ***"
            EXITCODE=69
            HOST
    }
    #end
    
     
    Last edited: Sep 1, 2008
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Do you use mailfir or mbox?
     
  3. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    I'm using Maildir
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    In case of maildir this recipe is not needed. Please make a copy of the procmailrc.master file and copy it to the customized_templates folder. In this file, remove the line that includes the quota recipe. Then edit the affected account in ISPConfig and click on save so that the config file is updated.
     
  5. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    Yeah I think I remember now ;-)

    Nevertheless, one could simply disable this, since the system should know whether to use mailboxes or maildirs (set in Management -> Server Settings)

    Also, I used my custom solution because I found the standard message that the user is over quota is not understood by the average user to whom mail might be returned.
     

Share This Page