Install optional rspamd scripts

This commit is contained in:
Tobias Herre 2023-11-03 08:53:12 +01:00
parent d8b4a6b58d
commit 0e07daa5f1
1 changed files with 102 additions and 5 deletions

View File

@ -5,7 +5,9 @@
bundle agent dovecot(cfg)
{
classes:
"use_ssl" expression => strcmp("$(cfg[ssl])","true");
"use_ssl" expression => strcmp("$(cfg[ssl])","true");
"rspamd_scripts" expression => strcmp("$(cfg[rspamd_scripts])","true");
vars:
freebsd::
"cfg_dir" string => "/usr/local/etc/dovecot";
@ -75,6 +77,9 @@ methods:
"any" usebundle => wmde_install_packages(@(pkgs),"dovecot");
"any" usebundle => wmde_service("$(service_name)","dovecot_kept","dovecot_repaired"),
depends_on => @(service_deps);
rspamd_scripts::
"any" usebundle => dovecot_install_rspamd_sieve_scripts("$(dovecot.cfg_dir)/rspamd"),
depends_on => {"dovecot_pkgs_installed"};
files:
"$(cfg_dir)/."
@ -166,6 +171,7 @@ bundle agent install_global_sieve_script( filename , content)
{
vars:
"rep_class" string =>"global_sieve_repaired_$(filename)";
files:
"$(filename)"
create => "true",
@ -175,12 +181,103 @@ files:
classes => if_repaired (sieve_repaired);
commands:
# sieve_repaired::
# "$(dovecot.sievec_exe)"
# args => "$(filename)",
# depends_on => { "global_sieve_$(filename)_created" };
sieve_repaired::
"$(dovecot.sievec_exe)"
args => "$(filename)",
depends_on => { "global_sieve_$(filename)_created" };
reports:
}
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"};
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:
"LOADER: $(def.wmde_lib)/scripts/dovecot/rspamd-learn-ham.sieve.mustache";
}