aboutsummaryrefslogtreecommitdiff
path: root/modules/private/mail/scan_reported_mails
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-23 21:04:55 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-29 15:14:43 +0200
commita929614f94d11a4f397e72e74f38b3212c24cdee (patch)
treea81b3cee45586d685c1b7c6e5c39372f203aa00d /modules/private/mail/scan_reported_mails
parent53fa9f9e7d87835d6137a029fe80b3195e635797 (diff)
downloadNix-a929614f94d11a4f397e72e74f38b3212c24cdee.tar.gz
Nix-a929614f94d11a4f397e72e74f38b3212c24cdee.tar.zst
Nix-a929614f94d11a4f397e72e74f38b3212c24cdee.zip
Configure mail (dovecot, postfix, spam checks)
Diffstat (limited to 'modules/private/mail/scan_reported_mails')
-rwxr-xr-xmodules/private/mail/scan_reported_mails21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/private/mail/scan_reported_mails b/modules/private/mail/scan_reported_mails
new file mode 100755
index 0000000..fe9f4d6
--- /dev/null
+++ b/modules/private/mail/scan_reported_mails
@@ -0,0 +1,21 @@
1#!/usr/bin/env bash
2
3( flock -n 9 || exit 1
4shopt -s nullglob
5for spool in /var/lib/vhost/.rspamd/*/pending; do
6 rspamd_folder=$(dirname $spool)
7 mail_user=$(basename $rspamd_folder)
8 mv $rspamd_folder/pending $rspamd_folder/processing
9
10 for mtype in ham spam; do
11 if [ -d $rspamd_folder/processing/$mtype ]; then
12 output="$(rspamc -h /run/rspamd/worker-controller.sock -c bayes -d $mail_user learn_$mtype $rspamd_folder/processing/$mtype/*)"
13 echo "[$mtype: $mail_user]" ${output} >> /var/lib/vhost/.rspamd/rspamd.log
14 mkdir -p $rspamd_folder/processed/$mtype
15 cp $rspamd_folder/processing/$mtype/* $rspamd_folder/processed/$mtype/
16 fi
17 done
18
19 rm -rf $rspamd_folder/processing
20done
21) 9>/var/lib/vhost/scan_reported_mails.lock