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 mailbox@domain.tld -c /etc/dovecot/dovecot.conf
    From: noreply@domain.co.za
    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.

Sayajin
  • 169
  • 2
  • 10
  • 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 07 '14 at 07: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 07 '14 at 08:17
  • Your LDA is dovecot, correct? – NickW Mar 07 '14 at 09: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 07 '14 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 07 '14 at 10:38
  • Never set the permission of anything to 777. – Dennis Williamson Mar 08 '14 at 08:31
  • @DennisWilliamson It was set to 777 purely for testing purposes – Sayajin Mar 10 '14 at 07:06
  • Yeah, if you're using dovecot to deliver, have you set up dovecot-dict-quota? – NickW Mar 10 '14 at 09:25
  • @NickW Yes dovecot is delivering. I setup the `maildir:User quota` one, still looking into the `dict:User quota::proxy::quota` option, but no time atm :) – Sayajin Mar 10 '14 at 11:48
  • The dict-quota should be what you need then, best of luck when you have the time! – NickW Mar 10 '14 at 11:53
  • @NickW tnx for all the help :) much appreciated – Sayajin Mar 10 '14 at 11:58
  • No problems, glad I helped. – NickW Mar 10 '14 at 12:08

1 Answers1

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 :)

Sayajin
  • 169
  • 2
  • 10