aboutsummaryrefslogtreecommitdiffstats
path: root/roles/dovecot/templates/usr
diff options
context:
space:
mode:
Diffstat (limited to 'roles/dovecot/templates/usr')
-rw-r--r--roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-ham.sh.j27
-rw-r--r--roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-spam.sh.j27
-rw-r--r--roles/dovecot/templates/usr/local/bin/dovecot-archive.sh.j219
-rw-r--r--roles/dovecot/templates/usr/local/bin/dovecot-quota-warning.sh.j219
4 files changed, 52 insertions, 0 deletions
diff --git a/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-ham.sh.j2 b/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-ham.sh.j2
new file mode 100644
index 0000000..fbce0bc
--- /dev/null
+++ b/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-ham.sh.j2
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+exec /usr/bin/rspamc \
+ --hostname={{ dovecot_rspamd_host | quote }} \
+ --password={{ dovecot_rspamd_password | quote }} \
+ --key={{ dovecot_rspamd_pubkey | quote }} \
+ learn_ham
diff --git a/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-spam.sh.j2 b/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-spam.sh.j2
new file mode 100644
index 0000000..393c5ec
--- /dev/null
+++ b/roles/dovecot/templates/usr/lib/dovecot/sieve-pipe/report-spam.sh.j2
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+exec /usr/bin/rspamc \
+ --hostname={{ dovecot_rspamd_host | quote }} \
+ --password={{ dovecot_rspamd_password | quote }} \
+ --key={{ dovecot_rspamd_pubkey | quote }} \
+ learn_spam
diff --git a/roles/dovecot/templates/usr/local/bin/dovecot-archive.sh.j2 b/roles/dovecot/templates/usr/local/bin/dovecot-archive.sh.j2
new file mode 100644
index 0000000..8f34b6a
--- /dev/null
+++ b/roles/dovecot/templates/usr/local/bin/dovecot-archive.sh.j2
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -Eeu -o pipefail
+
+VMAIL_USER={{ dovecot_vmail_user | quote }}
+{% raw %}
+TMPDIR=$(mktemp -d .dovecot-XXXXXX)
+trap 'rm -rf -- "$TMPDIR"' EXIT
+
+chown "$VMAIL_USER" "$TMPDIR"
+
+doveadm user '*' | xargs -r -I{} doveadm -o plugin/quota= backup -n inbox -f -u {} "mdbox:${TMPDIR}/{}/mdbox:LAYOUT=fs"
+
+TIMESTAMP=$(date +%Y%m%d%H%M%S)
+
+tar czf "mailboxes-${TIMESTAMP}.tar.gz" \
+ --transform "s|^\.|mailboxes-${TIMESTAMP}|" \
+ -C "$TMPDIR" .
+{% endraw %}
diff --git a/roles/dovecot/templates/usr/local/bin/dovecot-quota-warning.sh.j2 b/roles/dovecot/templates/usr/local/bin/dovecot-quota-warning.sh.j2
new file mode 100644
index 0000000..5ffe4b8
--- /dev/null
+++ b/roles/dovecot/templates/usr/local/bin/dovecot-quota-warning.sh.j2
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -Eeu -o pipefail
+
+PERCENT=$1
+USER=$2
+
+cat << EOF | /usr/libexec/dovecot/dovecot-lda -d "$USER" -o "plugin/quota=count:User quota:noenforcing"
+From: postmaster@{{ dovecot_default_domain }}
+Subject: Mailbox quota warning
+
+This is an automatically generated message.
+
+Your mailbox is now ${PERCENT}% full.
+
+When your mailbox exceeds its quota, you will no longer receive new mail.
+
+Please delete some messages to free up space.
+EOF