diff options
Diffstat (limited to 'modules/private/mail/scan_reported_mails')
-rwxr-xr-x | modules/private/mail/scan_reported_mails | 21 |
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 | ||
4 | shopt -s nullglob | ||
5 | for 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 | ||
20 | done | ||
21 | ) 9>/var/lib/vhost/scan_reported_mails.lock | ||