updated dovecot state
This commit is contained in:
parent
b44c2e9e36
commit
ad3cbfae87
@ -1,6 +1,5 @@
|
||||
---
|
||||
{%- from "dovecot/map.jinja" import dovecot with context %}
|
||||
|
||||
dovecot-imap-user:
|
||||
user.present:
|
||||
- name: {{ dovecot.imap_user }}
|
||||
@ -33,3 +32,23 @@ dovecot-config-conf.d-{{ name }}:
|
||||
- context:
|
||||
config: {{ config }}
|
||||
{%- 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 }}
|
||||
|
@ -5,6 +5,15 @@ dovecot:
|
||||
- dovecot-imapd
|
||||
- dovecot-lmtpd
|
||||
- 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_id: 2020
|
||||
config_dir: /etc/dovecot
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
{%- from "dovecot/map.jinja" import dovecot with context %}
|
||||
|
||||
dovecot-pkgs:
|
||||
pkg.installed:
|
||||
- pkgs: {{ dovecot.pkgs }}
|
||||
|
8
states/dovecot/templates/globalsieverc.j2
Normal file
8
states/dovecot/templates/globalsieverc.j2
Normal 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;
|
||||
}
|
16
states/dovecot/templates/report-ham.sieve.j2
Normal file
16
states/dovecot/templates/report-ham.sieve.j2
Normal 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}" ];
|
8
states/dovecot/templates/report-spam.sieve.j2
Normal file
8
states/dovecot/templates/report-spam.sieve.j2
Normal 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}" ];
|
2
states/dovecot/templates/train-ham.sh.j2
Normal file
2
states/dovecot/templates/train-ham.sh.j2
Normal 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
|
2
states/dovecot/templates/train-spam.sh.j2
Normal file
2
states/dovecot/templates/train-spam.sh.j2
Normal 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
|
5
states/dovecot/templates/update_sieve.sh.j2
Normal file
5
states/dovecot/templates/update_sieve.sh.j2
Normal 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 {} \;
|
Loading…
Reference in New Issue
Block a user