From 35f5fbb65aaa47f359e701b015ea98cb4be61206 Mon Sep 17 00:00:00 2001 From: Morre Date: Fri, 2 Oct 2020 14:50:20 +0200 Subject: [PATCH] add quota warnings --- files/quota-warning.sh | 10 ++++++++++ tasks/main.yml | 9 +++++++++ templates/90-quota.conf.j2 | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 files/quota-warning.sh diff --git a/files/quota-warning.sh b/files/quota-warning.sh new file mode 100644 index 0000000..bd944bd --- /dev/null +++ b/files/quota-warning.sh @@ -0,0 +1,10 @@ +#!/bin/sh +PERCENT=$1 +USER=$2 +cat << EOF | /usr/lib/dovecot/dovecot-lda -d $USER -o "plugin/quota=maildir:User quota:noenforcing" +From: postmaster@cccv.de +Subject: Quota warning + +Your mailbox is now $PERCENT% full. +Please consider archiving larger files in Nextcloud - a mail server is not a document archive. +EOF diff --git a/tasks/main.yml b/tasks/main.yml index 379903a..dc45c88 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,6 +30,15 @@ group: vmail mode: '0750' +- name: Create quota warning script + copy: + src: quota-warning.sh + dest: /usr/local/bin/quota-warning.sh + owner: vmail + group: vmail + mode: '554' + when: dovecot.quota + - name: copy dovecot config template: src: "{{ item.src }}" diff --git a/templates/90-quota.conf.j2 b/templates/90-quota.conf.j2 index d075172..85f297a 100644 --- a/templates/90-quota.conf.j2 +++ b/templates/90-quota.conf.j2 @@ -109,4 +109,20 @@ service quota-status { } client_limit = 1 } + +plugin { + quota_warning = storage=10%% quota-warning 10 %u + quota_warning2 = storage=80%% quota-warning 80 %u +} + +service quota-warning { + executable = script /usr/local/bin/quota-warning.sh + # use some unprivileged user for executing the quota warnings + user = vmail + unix_listener quota-warning { + user = vmail + group = vmail + } +} + {% endif %}