From 6f00048eca92d2a48792405cfdbe3b386e72aa40 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Tue, 1 Aug 2017 03:47:58 +0200 Subject: [PATCH] strongswan: convert init script to procd Signed-off-by: Stijn Tintel --- net/strongswan/files/ipsec.init | 41 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/net/strongswan/files/ipsec.init b/net/strongswan/files/ipsec.init index 0bbec766c..2d5000479 100644 --- a/net/strongswan/files/ipsec.init +++ b/net/strongswan/files/ipsec.init @@ -3,6 +3,9 @@ START=90 STOP=10 +USE_PROCD=1 +PROG=/usr/lib/ipsec/starter + . $IPKG_INSTROOT/lib/functions.sh IPSEC_SECRETS_FILE=/etc/ipsec.secrets @@ -315,21 +318,7 @@ prepare_env() { config_foreach config_remote remote } -start() { - prepare_env - ipsec start -} - -stop() { - ipsec stop -} - -restart() { - prepare_env - ipsec restart -} - -reload() { +reload_service() { prepare_env if ipsec status > /dev/null 2>&1; then ipsec rereadall @@ -338,3 +327,25 @@ reload() { ipsec start fi } + +service_triggers() { + procd_add_reload_trigger "ipsec" +} + +start_service() { + prepare_env + + procd_open_instance + + procd_set_param command $PROG --daemon charon --nofork + + procd_set_param file $IPSEC_CONN_FILE + procd_append_param file $IPSEC_SECRETS_FILE + procd_append_param file $STRONGSWAN_CONF_FILE + procd_append_param file /etc/strongswan.d/*.conf + procd_append_param file /etc/strongswan.d/charon/*.conf + + procd_set_param respawn + + procd_close_instance +}