restart_service method added

This commit is contained in:
Tobias Herre 2023-10-21 23:37:52 +02:00
parent 64a7f9dcf7
commit 6fe82e7b32
1 changed files with 18 additions and 2 deletions

20
lib.cf
View File

@ -103,15 +103,31 @@ bundle agent wmde_service(service_name,start_cond, restart_cond)
services:
"$(start_cond)"::
"$(service_name)"
service_policy => "start";
service_policy => "start",
handle => "$(handle)_service_started";
"$(restart_cond)"::
"$(service_name)"
service_policy => "restart";
service_policy => "restart",
handle => "$(handle)_service_restarted";
reports:
}
bundle agent wmde_restart_service(service_name, id)
{
commands:
debian::
"/bin/sh -c "
args => "'/bin/echo $(id) > /dev/null && /usr/bin/systemctl restart $(service_name)'";
freebsd::
"/bin/sh -c "
args => "'/bin/echo $(id) > /dev/null && /usr/sbin/service onerestart $(service_name)'";
}
body contain wmde_cmd_useshell
{
useshell=>"useshell";