Compare commits

...

2 Commits

2 changed files with 61 additions and 15 deletions

26
lib.cf
View File

@ -107,13 +107,35 @@ body service_method wmde
bundle agent wmde_service(service_name,start_cond, restart_cond) bundle agent wmde_service(service_name,start_cond, restart_cond)
{ {
classes:
freebsd::
"service_running" expression => returnszero("/usr/sbin/service $(service_name) onestatus >/dev/null 2>&1", "useshell");
commands:
"freebsd&(!service_running)&($(start_cond))"::
"/usr/sbin/service"
args => "$(service_name) onestart >/dev/null 2>&1",
contain => wmde_cmd_useshell,
handle => "$(handle)_service_started";
"freebsd&(service_running)&($(start_cond))"::
"/usr/bin/true"
inform => "false",
handle => "$(handle)_service_started";
"freebsd&($(restart_cond))"::
"/usr/sbin/service"
args => "$(service_name) onerestart >/dev/null 2>&1",
contain => wmde_cmd_useshell,
handle => "$(handle)_service_restarted";
services: services:
"$(start_cond)":: "(!freebsd)&($(start_cond))"::
"$(service_name)" "$(service_name)"
service_policy => "start", service_policy => "start",
handle => "$(handle)_service_started"; handle => "$(handle)_service_started";
"$(restart_cond)":: "(!freebsd)&($(restart_cond))"::
"$(service_name)" "$(service_name)"
service_policy => "restart", service_policy => "restart",
handle => "$(handle)_service_restarted"; handle => "$(handle)_service_restarted";

View File

@ -5,12 +5,30 @@
bundle agent strongswan bundle agent strongswan
{ {
vars: vars:
"ipsec_conf" string => "/etc/ipsec.conf"; freebsd::
"ipsec_secrets" string => "/etc/ipsec.secrets"; "pkgs" slist => {
"service_name" string => "ipsec"; "strongswan"
"pkgs" slist => { };
"strongswan" "ipsec_conf" string => "/usr/local/etc/ipsec.conf";
}; "ipsec_secrets" string => "/usr/local/etc/ipsec.secrets";
"service_name" string => "strongswan";
debian::
"pkgs" slist => {
"strongswan"
};
"ipsec_conf" string => "/etc/ipsec.conf";
"ipsec_secrets" string => "/etc/ipsec.secrets";
"service_name" string => "ipsec";
centos::
"pkgs" slist => {
"strongswan"
};
"ipsec_conf" string => "/etc/strongswan/ipsec.conf";
"ipsec_secrets" string => "/etc/strongswan/ipsec.secrets";
"service_name" string => "strongswan-starter";
} }
@ -18,15 +36,15 @@ vars:
bundle agent install_strongswan(cfg) bundle agent install_strongswan(cfg)
{ {
vars: vars:
"js" string => storejson(@(cfg)); "service_deps" slist => { "strongswan_ipsec_conf_ready", "strongswan_ipsec_secrets_ready" };
freebsd::
"service_deps" slist => { "strongswan_ipsec_conf_ready", "strongswan_ipsec_secrets_ready","strongswan_bsdcfg_ready" };
methods: methods:
"any" usebundle => wmde_install_packages(@(strongswan.pkgs),"strongswan"); "any" usebundle => wmde_install_packages(@(strongswan.pkgs),"strongswan");
"any" usebundle => wmde_service("$(strongswan.service_name)","strongswan_kept","strongswan_repaired"), "any" usebundle => wmde_service("$(strongswan.service_name)","strongswan_kept","strongswan_repaired"),
depends_on => { depends_on => @(service_deps);
"strongswan_ipsec_conf_ready",
"strongswan_ipsec_secrets_ready"
};
files: files:
"$(strongswan.ipsec_conf)" "$(strongswan.ipsec_conf)"
create => "true", create => "true",
@ -46,8 +64,14 @@ files:
classes => if_repaired("strongswan_repaired"), classes => if_repaired("strongswan_repaired"),
edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/strongswan-ipsec.secrets.mustache"; edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/strongswan-ipsec.secrets.mustache";
freebsd::
"/etc/rc.conf.d/strongswan"
create => "true",
content =>"strongswan_interface=stroke
strongswan_enable=\"YES\"
",
handle => "strongswan_bsdcfg_ready";
reports: reports:
} }