updated dovecot state

This commit is contained in:
Paul 2023-10-10 09:06:30 +02:00
parent b44c2e9e36
commit ad3cbfae87
9 changed files with 70 additions and 2 deletions

View File

@ -1,6 +1,5 @@
--- ---
{%- from "dovecot/map.jinja" import dovecot with context %} {%- from "dovecot/map.jinja" import dovecot with context %}
dovecot-imap-user: dovecot-imap-user:
user.present: user.present:
- name: {{ dovecot.imap_user }} - name: {{ dovecot.imap_user }}
@ -33,3 +32,23 @@ dovecot-config-conf.d-{{ name }}:
- context: - context:
config: {{ config }} config: {{ config }}
{%- endfor %} {%- endfor %}
dovecot-sieve-dir:
file.directory:
- name: {{ dovecot.sieve_dir }}
{%- if dovecot.sieve_configfiles %}
{%- for configfile in dovecot.sieve_configfiles %}
dovecot-sieve-configfile-{{ configfile }}:
file.managed:
- name: {{ dovecot.sieve_dir }}/{{ configfile }}
- mode: '0755'
- source: salt://dovecot/templates/{{ configfile }}.j2
- template: jinja
{%- endfor %}
{%- endif %}
dovecot-sieve-refresh:
cmd.run:
- name: "{{ dovecot.sieve_dir }}/update_sieve.sh"
- cwd: {{ dovecot.sieve_dir }}

View File

@ -5,6 +5,15 @@ dovecot:
- dovecot-imapd - dovecot-imapd
- dovecot-lmtpd - dovecot-lmtpd
- dovecot-pgsql - dovecot-pgsql
root_storage: /var/lib/vmail
sieve_dir: /var/lib/vmail/sieve
sieve_configfiles:
- globalsieverc
- report-ham.sieve
- report-spam.sieve
- train-ham.sh
- train-spam.sh
- update_sieve.sh
imap_user: vmail imap_user: vmail
imap_user_id: 2020 imap_user_id: 2020
config_dir: /etc/dovecot config_dir: /etc/dovecot

View File

@ -1,6 +1,5 @@
--- ---
{%- from "dovecot/map.jinja" import dovecot with context %} {%- from "dovecot/map.jinja" import dovecot with context %}
dovecot-pkgs: dovecot-pkgs:
pkg.installed: pkg.installed:
- pkgs: {{ dovecot.pkgs }} - pkgs: {{ dovecot.pkgs }}

View File

@ -0,0 +1,8 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
require ["fileinto"];
# Move spam to spam folder
if anyof (header :contains "X-Spam-Flag" "YES", header :is "X-Spam" "Yes") {
fileinto "Junk";
stop;
}

View File

@ -0,0 +1,16 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.email" "*" {
set "email" "${1}";
}
pipe :copy "train-ham.sh" [ "${email}" ];

View File

@ -0,0 +1,8 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.email" "*" {
set "email" "${1}";
}
pipe :copy "train-spam.sh" [ "${email}" ];

View File

@ -0,0 +1,2 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
exec /usr/bin/rspamc -h 127.0.0.1:11334 learn_ham

View File

@ -0,0 +1,2 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
exec /usr/bin/rspamc -h 127.0.0.1:11334 learn_spam

View File

@ -0,0 +1,5 @@
{%- from "dovecot/map.jinja" import dovecot with context -%}
#!/usr/bin/env sh
/usr/bin/find {{ dovecot.sieve_dir }} -name "*.sieve" -exec /usr/bin/sievec {} \;
/usr/bin/find {{ dovecot.root_storage }} -name "dovecot.sieve" -exec /usr/bin/sievec {} \;