2

I would like to run a custom script with dovecot once the user reaches certain percents of their quota.

The issue is that no matter what I try dovecot does not seem to execute my bash script.

90-quota.conf

plugin {
    quota_warning = storage=95%% quota-warning 95 %u
    quota_warning2 = storage=10%% quota-warning 10 %u
}

service quota-warning {
    executable = script /var/www/lighttpd/mail/scripts/quotaWarning.sh
    user = root
    unix_listener quota-warning {
        user = dovecot
        mode = 0666
    }
}

I have tried it with & without the user/mode/group arguments. I have also tried root/mail/dovecot users in all the different variations but with no luck at all.

quotaWarning.sh

#!/bin/sh

PERCENT="${1}"
USER="${2}"

cat <<EOF | /usr/libexec/dovecot/deliver -d [email protected] -c /etc/dovecot/dovecot.conf
    From: [email protected]
    Subject: Mailbox Quota Warning: ${PERCENT}% Full.

    Mailbox quota report:
    ${USER}
     * Your mailbox is now ${PERCENT}% full, please clear some files for further mails.

EOF
  • The scripts permissions are set to 777 & I have has it with both user & groups of root & dovecot.
  • Dovecot version is 2.2.7
  • I am running CentOS 6.5 64bit
  • Kernel: 2.6.32-042stab078.26

Any assistance would be awesome since I am now at a loss.

12
  • The script would only be executed at the time that the mail delivery causes the quota to exceed the limit. If the user is already over quota, it will not be executed. Could this be the case here?
    – Jenny D
    Mar 7, 2014 at 7:27
  • - This might very well be the case, if there anyway to cause it to run the script each time the user logs in (for debuging purpose only), If not then if I remove the large email, close open email client, put the large email back, close open email client, will the script execute? Also any hints on what the correct user = username should be?
    – Sayajin
    Mar 7, 2014 at 8:17
  • Your LDA is dovecot, correct?
    – NickW
    Mar 7, 2014 at 9:31
  • I ask, because this is very important: You can configure Dovecot to run an external command when user's quota exceeds a specified limit. Note that the warning is ONLY executed at the exact time when the limit is being crossed, so when you're testing it you have to do it by crossing the limit by saving a new mail. If something else besides Dovecot updates quota so that the limit is crossed, the warning is never executed.
    – NickW
    Mar 7, 2014 at 10:18
  • Yes dovecot is my LDA, and as Jenny D mentioned it was just the case that I had to go below the limit & then exceed it again for the script to execute (tnx Jenny), so its all working correctly now. The only strange issue i'm having now is that the maildirsize file doesn't always automatically update, so I have to remove it & then it recreates with the new correct size in it. Any idea's on that one? Also would there be a way to have the maildirsize info saved into the mysql DB?
    – Sayajin
    Mar 7, 2014 at 10:38

1 Answer 1

1

Reason it didn't seem to be working was due to me not thinking it through, since it would only execute the script the first time it goes over quota & not each time you check your email.

tnx for the help :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .