Sets password only if changed

This commit is contained in:
Tobias Herre 2023-11-03 12:54:27 +01:00
parent 9b76402251
commit e2517d06f6
1 changed files with 33 additions and 7 deletions

View File

@ -8,6 +8,14 @@ classes:
"runpw" expression => isvariable("cfg[password]");
vars:
"tpl_deps" slist => { "rspamd_pkgs_installed","rspamd_cfg_dir_created" };
runpw::
"tpl_deps" slist => { "rspamd_pkgs_installed","rspamd_cfg_dir_created","rspamd_password_ready" };
any::
"cfgfiles" slist => {
"local.d/milter_headers.conf",
# "local.d/actions.conf",
@ -44,11 +52,32 @@ vars:
"root_group" string => "root";
"rspamadm" string => "/usr//bin/rspamadm";
any::
"password" string => execresult("$(rspamadm) pw -p $(cfg[password])","noshell");
runpw::
"password" string => readfile("$(sys.workdir)/data/agent/rspamd/password-hash.txt"),
handle => "rspamd_password_ready",
depends_on => {"rspamd_password_hash_created"};
files:
runpw::
"$(sys.workdir)/data/agent/rspamd/password.txt"
create => "true",
content => "$(cfg[password])",
handle => "rspamd_password_created",
classes => if_repaired("rspamd_password_repaired");
rspamd_password_repaired::
"$(sys.workdir)/data/agent/rspamd/password-hash.txt"
content => execresult("$(rspamadm) pw -p $(cfg[password])","noshell"),
depends_on => {"rspamd_password_created"},
handle => "rspamd_password_hash_created";
commands:
!rspamd_password_repaired::
"/usr/bin/true"
depends_on => {"rspamd_password_created"},
handle => "rspamd_password_hash_created",
inform => "false";
methods:
"any" usebundle => install_rspamd_pkgs;
@ -67,16 +96,13 @@ files:
template_method => "mustache",
perms => m("644"),
template_data => bundlestate("$(this.bundle)"),
depends_on => { "rspamd_pkgs_installed","rspamd_cfg_dir_created" },
depends_on => @(tpl_deps),
classes => if_repaired(rspamd_repaired),
handle => "rspamd_cfgs_done";
reports:
# "RSPAMD: $(cfgjs)";
# "RSJ: $(worker_normalx)";
}