2023-10-11 16:14:28 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
bundle agent dovecot(cfg)
|
|
|
|
{
|
2023-10-31 16:25:32 +00:00
|
|
|
classes:
|
2023-11-03 07:53:12 +00:00
|
|
|
"use_ssl" expression => strcmp("$(cfg[ssl])","true");
|
|
|
|
"rspamd_scripts" expression => strcmp("$(cfg[rspamd_scripts])","true");
|
2023-11-06 08:19:42 +00:00
|
|
|
"global_sieve_after" expression => strcmp("$(cfg[global_sieve_after])","true");
|
2023-10-11 16:14:28 +00:00
|
|
|
vars:
|
2023-11-04 21:08:02 +00:00
|
|
|
"imap_key" string => "$(cfg_dir)/private/imap.key";
|
|
|
|
"imap_cert" string => "$(cfg_dir)/private/imap.crt";
|
|
|
|
"submission_key" string => "$(cfg_dir)/private/submission.key";
|
|
|
|
"submission_cert" string => "$(cfg_dir)/private/submission.crt";
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-11 16:14:28 +00:00
|
|
|
freebsd::
|
2023-11-03 18:38:18 +00:00
|
|
|
"service_name" string => "dovecot";
|
2023-10-11 16:14:28 +00:00
|
|
|
"cfg_dir" string => "/usr/local/etc/dovecot";
|
|
|
|
"dovecot_conf" string => "$(cfg_dir)/dovecot.conf";
|
|
|
|
|
|
|
|
"pkgs" slist => {
|
2023-11-04 21:08:02 +00:00
|
|
|
"dovecot",
|
|
|
|
"dovecot-pigeonhole"
|
2023-10-11 16:14:28 +00:00
|
|
|
};
|
2023-11-04 21:08:02 +00:00
|
|
|
"sievec_exe" string => "/usr/local/bin/sievec";
|
2023-10-11 16:14:28 +00:00
|
|
|
debian::
|
|
|
|
"cfg_dir" string => "/etc/dovecot";
|
|
|
|
"dovecot_conf" string => "$(cfg_dir)/dovecot.conf";
|
|
|
|
|
|
|
|
"imap_key" string => "$(cfg_dir)/private/imap.key";
|
|
|
|
"imap_cert" string => "$(cfg_dir)/private/imap.crt";
|
2023-10-14 13:15:30 +00:00
|
|
|
"submission_key" string => "$(cfg_dir)/private/submission.key";
|
|
|
|
"submission_cert" string => "$(cfg_dir)/private/submission.crt";
|
|
|
|
|
2023-10-31 19:33:56 +00:00
|
|
|
"sievec_exe" string => "/usr/bin/sievec";
|
2023-10-11 16:14:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
"service_name" string => "dovecot";
|
|
|
|
"pkgs" slist => {
|
|
|
|
"dovecot-core",
|
|
|
|
"dovecot-mysql",
|
|
|
|
"dovecot-managesieved",
|
2023-10-20 18:01:07 +00:00
|
|
|
# "dovecot-submissiond",
|
2023-10-11 16:14:28 +00:00
|
|
|
"dovecot-lmtpd",
|
|
|
|
"dovecot-imapd",
|
|
|
|
"dovecot-pop3d"
|
|
|
|
|
|
|
|
};
|
2023-10-27 23:08:46 +00:00
|
|
|
centos::
|
|
|
|
"pkgs" slist => {
|
|
|
|
"dovecot",
|
|
|
|
"dovecot-mysql",
|
2023-10-29 23:29:16 +00:00
|
|
|
"dovecot-pigeonhole"
|
2023-10-27 23:08:46 +00:00
|
|
|
};
|
|
|
|
"cfg_dir" string => "/etc/dovecot";
|
|
|
|
"dovecot_conf" string => "$(cfg_dir)/dovecot.conf";
|
|
|
|
|
|
|
|
"imap_key" string => "$(cfg_dir)/private/imap.key";
|
|
|
|
"imap_cert" string => "$(cfg_dir)/private/imap.crt";
|
|
|
|
"submission_key" string => "$(cfg_dir)/private/submission.key";
|
|
|
|
"submission_cert" string => "$(cfg_dir)/private/submission.crt";
|
|
|
|
"service_name" string => "dovecot";
|
2023-10-31 19:33:56 +00:00
|
|
|
"sievec_exe" string => "/usr/bin/sievec";
|
2023-10-27 23:08:46 +00:00
|
|
|
|
2023-10-31 16:25:32 +00:00
|
|
|
use_ssl::
|
|
|
|
"service_deps" slist => {
|
2023-10-11 16:14:28 +00:00
|
|
|
"dovecot_pkgs_installed",
|
2023-10-14 13:15:30 +00:00
|
|
|
"dovecot_cfg_created",
|
2023-10-11 16:14:28 +00:00
|
|
|
"dovecot_imap_key_installed",
|
|
|
|
"dovecot_imap_cert_installed",
|
2023-10-14 13:15:30 +00:00
|
|
|
"dovecot_submission_key_installed",
|
|
|
|
"dovecot_submission_cert_installed",
|
2023-10-11 16:14:28 +00:00
|
|
|
};
|
2023-10-31 16:25:32 +00:00
|
|
|
!use_ssl::
|
|
|
|
"service_deps" slist => {
|
|
|
|
"dovecot_pkgs_installed",
|
|
|
|
"dovecot_cfg_created",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methods:
|
|
|
|
"any" usebundle => wmde_install_packages(@(pkgs),"dovecot");
|
|
|
|
"any" usebundle => wmde_service("$(service_name)","dovecot_kept","dovecot_repaired"),
|
|
|
|
depends_on => @(service_deps);
|
2023-11-03 07:53:12 +00:00
|
|
|
"any" usebundle => dovecot_install_rspamd_sieve_scripts("$(dovecot.cfg_dir)/rspamd"),
|
|
|
|
depends_on => {"dovecot_pkgs_installed"};
|
2023-10-11 16:14:28 +00:00
|
|
|
|
2023-11-06 08:19:42 +00:00
|
|
|
|
2023-10-11 16:14:28 +00:00
|
|
|
files:
|
2023-10-11 21:58:45 +00:00
|
|
|
"$(cfg_dir)/."
|
|
|
|
create => "true",
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("755"),
|
2023-10-11 21:58:45 +00:00
|
|
|
depends_on => {"dovecot_pkgs_installed"},
|
|
|
|
handle => "dovecot_cfg_dir_created";
|
|
|
|
|
2023-10-11 16:14:28 +00:00
|
|
|
"$(dovecot_conf)"
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
|
|
|
create => "true",
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("644"),
|
2023-10-11 16:14:28 +00:00
|
|
|
template_method => "mustache",
|
2023-10-11 21:58:45 +00:00
|
|
|
depends_on => {"dovecot_pkgs_installed","dovecot_cfg_dir_created"},
|
2023-10-11 16:14:28 +00:00
|
|
|
handle => "dovecot_cfg_created",
|
|
|
|
edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/dovecot/dovecot.conf.mustache";
|
|
|
|
|
2023-10-31 16:25:32 +00:00
|
|
|
use_ssl::
|
2023-10-11 16:14:28 +00:00
|
|
|
|
2023-10-31 16:25:32 +00:00
|
|
|
"$(imap_cert)"
|
|
|
|
handle => "dovecot_imap_cert_installed",
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
2023-11-04 21:08:02 +00:00
|
|
|
copy_from => local_dcp( execresult( "/usr/bin/readlink -fn $(cfg[imap_cert])","noshell" )),
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("600");
|
2023-10-11 16:14:28 +00:00
|
|
|
|
2023-10-31 16:25:32 +00:00
|
|
|
"$(imap_key)"
|
|
|
|
handle => "dovecot_imap_key_installed",
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
2023-11-04 21:08:02 +00:00
|
|
|
copy_from => local_dcp( execresult( "/usr/bin/readlink -fn $(cfg[imap_key])","noshell" )),
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("600");
|
2023-10-14 13:15:30 +00:00
|
|
|
|
2023-10-31 16:25:32 +00:00
|
|
|
"$(submission_cert)"
|
|
|
|
handle => "dovecot_submission_cert_installed",
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
2023-11-04 21:08:02 +00:00
|
|
|
copy_from => local_dcp( execresult( "/usr/bin/readlink -fn $(cfg[submission_cert])","noshell" )),
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("600");
|
2023-10-31 16:25:32 +00:00
|
|
|
|
|
|
|
"$(submission_key)"
|
|
|
|
handle => "dovecot_submission_key_installed",
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
2023-11-04 21:08:02 +00:00
|
|
|
copy_from => local_dcp( execresult( "/usr/bin/readlink -fn $(cfg[submission_key])","noshell" )),
|
2023-11-03 18:38:18 +00:00
|
|
|
perms => m("600");
|
2023-10-14 13:15:30 +00:00
|
|
|
|
2023-10-11 16:14:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reports:
|
2023-11-01 21:10:15 +00:00
|
|
|
# use_ssl::
|
|
|
|
# "USE_SSL: TRUE";
|
|
|
|
# !use_ssl::
|
|
|
|
# "USE_SSL: FALSE";
|
2023-10-31 16:25:32 +00:00
|
|
|
|
2023-10-12 18:21:02 +00:00
|
|
|
# "IMAP_CERT: $(imap_cert)";
|
|
|
|
#
|
|
|
|
# dovecot_kept::
|
|
|
|
# "DOVECOT kept";
|
|
|
|
#
|
|
|
|
# dovecot_repaired::
|
|
|
|
# "DOVECOT repaired";
|
2023-10-11 16:14:28 +00:00
|
|
|
|
|
|
|
}
|
2023-10-11 21:58:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-29 00:08:20 +00:00
|
|
|
bundle agent dovecot_vimbadmin_sql(cfg,dovecot_cfg)
|
2023-10-11 21:58:45 +00:00
|
|
|
{
|
|
|
|
vars:
|
|
|
|
"cfg_file" string => "$(sys.workdir)/data/agent/dovecot/vimbadmin-sql.comf";
|
|
|
|
files:
|
|
|
|
"$(cfg_file)"
|
|
|
|
classes => if_repaired(dovecot_repaired),
|
|
|
|
create => "true",
|
|
|
|
template_method => "mustache",
|
|
|
|
edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/dovecot/vimbadmin-sql.conf.mustache";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-31 16:25:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
bundle agent install_dovecot_pkgs
|
|
|
|
{
|
|
|
|
methods:
|
|
|
|
"any" usebundle => wmde_install_packages(@(dovecot.pkgs),"dovecot");
|
|
|
|
}
|
2023-10-31 19:33:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
bundle agent install_global_sieve_script( filename , content)
|
|
|
|
{
|
|
|
|
vars:
|
|
|
|
"rep_class" string =>"global_sieve_repaired_$(filename)";
|
2023-11-03 07:53:12 +00:00
|
|
|
|
2023-10-31 19:33:56 +00:00
|
|
|
files:
|
|
|
|
"$(filename)"
|
|
|
|
create => "true",
|
|
|
|
content => "$(content)",
|
|
|
|
perms => m("644"),
|
|
|
|
handle => "global_sieve_$(filename)_created",
|
|
|
|
classes => if_repaired (sieve_repaired);
|
|
|
|
|
|
|
|
commands:
|
2023-11-03 07:53:12 +00:00
|
|
|
sieve_repaired::
|
|
|
|
"$(dovecot.sievec_exe)"
|
|
|
|
args => "$(filename)",
|
|
|
|
depends_on => { "global_sieve_$(filename)_created" };
|
2023-10-31 19:33:56 +00:00
|
|
|
reports:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-11-03 07:53:12 +00:00
|
|
|
bundle agent dovecot_install_sieve_script( filename , content, cls)
|
|
|
|
{
|
|
|
|
vars:
|
|
|
|
"rep_class" string =>"global_sieve_$(filename)_repaired";
|
|
|
|
|
|
|
|
files:
|
|
|
|
"$(filename)"
|
|
|
|
create => "true",
|
|
|
|
content => "$(content)",
|
|
|
|
perms => m("644"),
|
|
|
|
handle => "sieve_$(filename)_created",
|
|
|
|
classes => if_repaired ("$(cls)_repaired");
|
|
|
|
|
|
|
|
commands:
|
|
|
|
"$(cls)_repaired"::
|
|
|
|
"$(dovecot.sievec_exe)"
|
|
|
|
args => "$(filename)",
|
|
|
|
depends_on => { "sieve_$(filename)_created" };
|
|
|
|
reports:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bundle agent dovecot_rspamd_sieve_vars(read)
|
|
|
|
{
|
|
|
|
classes:
|
|
|
|
"$(read)";
|
|
|
|
vars:
|
|
|
|
# do_read::
|
|
|
|
# "ham_script" string => readfile("$(def.wmde_lib/scripts/rspamd-learn-ham.sieve.mustache)");
|
|
|
|
# "spam_script" string => readfile("$(def.wmde_lib/scripts/rspamd-learn-ham.sieve.mustache)");
|
|
|
|
# "ham_sh" string => readfile("$(def.wmde_lib/scripts/rspamd-learn-ham.sieve.mustache)");
|
|
|
|
# "spam_sh" string => readfile("$(def.wmde_lib/scripts/rspamd-learn-ham.sieve.mustache)");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bundle agent dovecot_install_rspamd_sieve_scripts(target_dir)
|
|
|
|
{
|
|
|
|
methods:
|
|
|
|
"any" usebundle => dovecot_rspamd_sieve_vars("do_read"),
|
|
|
|
handle => "dovecot_rspamd_vars_ready";
|
|
|
|
files:
|
|
|
|
"$(target_dir)/."
|
|
|
|
create => "true",
|
|
|
|
perms => m("755"),
|
|
|
|
handle => "dovecot_install_rspamd_sieve_scripts_dir_created";
|
|
|
|
|
|
|
|
methods:
|
|
|
|
"any" usebundle => dovecot_install_sieve_script( "$(target_dir)/rspamd-learn-ham.sieve",
|
|
|
|
# string_mustache(
|
|
|
|
readfile("$(def.wmde_lib)/scripts/dovecot/rspamd-learn-ham.sieve.mustache")
|
|
|
|
# ),
|
|
|
|
, "dovecot_sieve_ham"
|
|
|
|
) ,depends_on => {"dovecot_install_rspamd_sieve_scripts_dir_created"};
|
|
|
|
"any" usebundle => dovecot_install_sieve_script( "$(target_dir)/rspamd-learn-spam.sieve",
|
|
|
|
# string_mustache(
|
|
|
|
readfile("$(def.wmde_lib)/scripts/dovecot/rspamd-learn-spam.sieve.mustache")
|
|
|
|
# )
|
|
|
|
, "dovecot_sieve_spam"
|
|
|
|
|
|
|
|
) ,depends_on => {"dovecot_install_rspamd_sieve_scripts_dir_created"};
|
|
|
|
|
2023-11-06 08:19:42 +00:00
|
|
|
|
|
|
|
"any" usebundle => dovecot_install_sieve_script("$(target_dir)/global_sieve_after.sieve",
|
|
|
|
'
|
|
|
|
require ["fileinto"];
|
|
|
|
if allof (header :contains "X-Spam" "Yes")
|
|
|
|
{
|
|
|
|
fileinto "Junk";
|
|
|
|
}
|
|
|
|
|
|
|
|
',"dovecot_global_sieve_after"),depends_on => {
|
|
|
|
"dovecot_install_rspamd_sieve_scripts_dir_created",
|
|
|
|
"dovecot_pkgs_installed"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-11-03 07:53:12 +00:00
|
|
|
files:
|
|
|
|
|
|
|
|
"$(target_dir)/rspamd-learn-ham.sh"
|
|
|
|
create => "true",
|
|
|
|
content => string_mustache(
|
|
|
|
readfile("$(def.wmde_lib)/scripts/dovecot/rspamd-learn-ham.sh.mustache")
|
|
|
|
),
|
|
|
|
perms => m("755"),
|
|
|
|
depends_on => {"dovecot_install_rspamd_sieve_scripts_dir_created"};
|
|
|
|
|
|
|
|
"$(target_dir)/rspamd-learn-spam.sh"
|
|
|
|
create => "true",
|
|
|
|
content => string_mustache(
|
|
|
|
readfile("$(def.wmde_lib)/scripts/dovecot/rspamd-learn-spam.sh.mustache")
|
|
|
|
),
|
|
|
|
perms => m("755"),
|
|
|
|
depends_on => {"dovecot_install_rspamd_sieve_scripts_dir_created"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reports:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-31 19:33:56 +00:00
|
|
|
|