From 1f932fd5ecd000a2218da91d3c6c9a28055d4b4c Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Tue, 11 Oct 2022 14:19:57 -0400 Subject: [PATCH] Issue #526: Fix dovecot quota warnings --- .../templates/dovecot/conf.d/95_alternc.conf | 13 +++++++++++-- src/quota-warning.sh | 13 +++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/etc/alternc/templates/dovecot/conf.d/95_alternc.conf b/etc/alternc/templates/dovecot/conf.d/95_alternc.conf index a6713cb3..39ad880b 100644 --- a/etc/alternc/templates/dovecot/conf.d/95_alternc.conf +++ b/etc/alternc/templates/dovecot/conf.d/95_alternc.conf @@ -300,8 +300,8 @@ plugin { # Note that % needs to be escaped as %%, otherwise "% " expands to empty. # quota_warning = storage=95%% /usr/local/bin/quota-warning.sh 95 # quota_warning2 = storage=80%% /usr/local/bin/quota-warning.sh 80 - quota_warning = storage=95%% /usr/lib/alternc/quota-warning.sh 95 - quota_warning2 = storage=80%% /usr/lib/alternc/quota-warning.sh 80 + quota_warning = storage=95%% quota-warning 95 %u + quota_warning2 = storage=80%% quota-warning 80 %u #quota = maildir quota = dict:user::proxy::quotadict @@ -317,6 +317,15 @@ plugin { sieve_dir=~/sieve } +service quota-warning { + executable = script /usr/lib/alternc/quota-warning.sh + unix_listener quota-warning { + mode = 0660 + user = vmail + group = vmail + } +} + # Dictionary can be used by some plugins to store key=value lists, such as # quota, expire and acl plugins. The dictionary can be used either directly or # though a dictionary server. The following dict block maps dictionary names to diff --git a/src/quota-warning.sh b/src/quota-warning.sh index b8e26d26..141408a5 100755 --- a/src/quota-warning.sh +++ b/src/quota-warning.sh @@ -1,16 +1,17 @@ #!/bin/bash -PERCENT=$1 -DOM="`echo $USER | sed -e 's/.*@//'`" +PERCENT="$1" +MAILUSER="$2" +DOM="$(echo "${MAILUSER}" | sed -e 's/.*@//')" FROM="postmaster@$DOM" -msg="From: $FROM -To: $USER +cat <