restores password-has.txt if deleted

This commit is contained in:
Tobias Herre 2023-11-06 21:42:41 +01:00
parent d7e0b3a461
commit 40c6b6aa6c
1 changed files with 19 additions and 5 deletions

View File

@ -69,14 +69,15 @@ files:
handle => "rspamd_password_created", handle => "rspamd_password_created",
classes => if_repaired("rspamd_password_repaired"); classes => if_repaired("rspamd_password_repaired");
rspamd_password_repaired:: methods:
"$(sys.workdir)/data/agent/rspamd/password-hash.txt" runpw::
content => execresult("$(rspamadm) pw -p $(cfg[password])","noshell"), "any" usebundle => rspamd_create_password_hash,
depends_on => {"rspamd_password_created"}, depends_on => {"rspamd_password_created"},
handle => "rspamd_password_hash_created"; handle => "rspamd_password_hash_created";
commands: commands:
!rspamd_password_repaired:: !runpw::
"/usr/bin/true" "/usr/bin/true"
depends_on => {"rspamd_password_created"}, depends_on => {"rspamd_password_created"},
handle => "rspamd_password_hash_created", handle => "rspamd_password_hash_created",
@ -109,6 +110,19 @@ reports:
} }
bundle agent rspamd_create_password_hash
{
classes:
"no_hash_file" expression => not(fileexists("$(sys.workdir)/data/agent/rspamd/password-hash.txt"));
files:
rspamd_password_repaired|no_hash_file::
"$(sys.workdir)/data/agent/rspamd/password-hash.txt"
content => execresult("$(rspamd.rspamadm) pw -p $(rspamd.cfg[password])","noshell"),
handle => "rspamd_password_hash_created";
}
bundle agent rspamd_install_yum_repo bundle agent rspamd_install_yum_repo
{ {
classes: classes: