From 6ba876f10c6dd302ae8c7ba2e587ea9e6472e77e Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Sat, 25 Aug 2012 11:29:36 +0000 Subject: [PATCH] adding quota-warning for dovecot + fixing dovecot conf --- .gitattributes | 1 + etc/alternc/templates/dovecot/dovecot-sql.conf | 2 +- etc/alternc/templates/dovecot/dovecot.conf | 4 ++-- src/Makefile | 2 +- src/quota-warning.sh | 16 ++++++++++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/quota-warning.sh diff --git a/.gitattributes b/.gitattributes index 26f15c85..7ea09f21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -531,6 +531,7 @@ src/functions_hosting.sh -text src/mail_deletion.sh -text src/mem_add -text src/mem_del -text +src/quota-warning.sh -text src/quota_delete -text src/quota_edit -text src/quota_get -text diff --git a/etc/alternc/templates/dovecot/dovecot-sql.conf b/etc/alternc/templates/dovecot/dovecot-sql.conf index d4206960..9d2e379e 100644 --- a/etc/alternc/templates/dovecot/dovecot-sql.conf +++ b/etc/alternc/templates/dovecot/dovecot-sql.conf @@ -116,7 +116,7 @@ default_pass_scheme = MD5 # user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u' # user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u' # -user_query = SELECT mailbox.path AS home, domaines.compte AS uid, 1998 AS gid FROM mailbox JOIN address ON address.id = mailbox.address_id JOIN domaines on domaines.id = address.domain_id WHERE address.address = '%n' +user_query = SELECT userdb_home AS home, userdb_uid AS uid, 1998 AS gid, userdb_quota_rule AS quota_rule FROM dovecot_view WHERE user = '%u'; # If you wish to avoid two SQL lookups (passdb + userdb), you can use # userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll diff --git a/etc/alternc/templates/dovecot/dovecot.conf b/etc/alternc/templates/dovecot/dovecot.conf index 22160101..e7232831 100644 --- a/etc/alternc/templates/dovecot/dovecot.conf +++ b/etc/alternc/templates/dovecot/dovecot.conf @@ -1214,8 +1214,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/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 = maildir quota = dict:user::proxy::quotadict diff --git a/src/Makefile b/src/Makefile index be2707c2..bf19a35f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -26,7 +26,7 @@ # ---------------------------------------------------------------------- # SETUID=mail_add mail_del quota_edit quota_get mem_add mem_del du.pl -SCRIPTS=sqlbackup.sh rawstat.daily quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh +SCRIPTS=sqlbackup.sh rawstat.daily quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh LIBS=functions.sh functions_hosting.sh functions_dns.sh BIN=$(DESTDIR)/usr/lib/alternc/ diff --git a/src/quota-warning.sh b/src/quota-warning.sh new file mode 100644 index 00000000..06bab04e --- /dev/null +++ b/src/quota-warning.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +PERCENT=$1 +DOM="`echo $USER | sed -e 's/.*@//'`" +FROM="postmaster@$DOM" + +msg="From: $FROM +To: $USER +Subject: Your email quota is $PERCENT% full +Content-Type: text/plain; charset=UTF-8 + +Your mailbox is now $PERCENT% full." + +echo -e "$msg" | /usr/sbin/sendmail -f $FROM "$USER" + +exit 0