From: Florian Eckert Date: Thu, 9 Jul 2026 12:05:53 +0000 (+0200) Subject: strongswan: move strongswan.conf generation to its own function X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=8c2c290a4696c27180b40c1727638fe8b9141615;p=openwrt-packages.git strongswan: move strongswan.conf generation to its own function The cross-file handling of variables that are populated in 'config_ipsec' but then written to 'strongswan.conf' in the 'do postamble' section is prone to errors, as variables are often overlooked. The config file 'strongswan.conf' is now generated in a single function without the need to use global variables. This commit does not change the function and is a preparatory commit. Signed-off-by: Florian Eckert --- diff --git a/net/strongswan/files/swanctl.init b/net/strongswan/files/swanctl.init index 57def8809..1e8069cb3 100644 --- a/net/strongswan/files/swanctl.init +++ b/net/strongswan/files/swanctl.init @@ -655,6 +655,8 @@ config_remote() { config_ipsec() { local conf="$1" + local debug install_routes routing_tables_ignored device_list + local rtinstall_enabled local routing_table local routing_table_id @@ -687,10 +689,7 @@ config_ipsec() { done [ -n "$device_list" ] && WAIT_FOR_INTF=0 || WAIT_FOR_INTF=1 fi -} -do_postamble() { - swan_xappend0 "# generated by /etc/init.d/swanctl" swan_xappend0 "charon {" swan_xappend1 "install_routes = $install_routes" [ -n "$routing_tables_ignored" ] && swan_xappend1 "ignore_routing_tables = $routing_tables_ignored" @@ -710,15 +709,12 @@ do_postamble() { prepare_env() { mkdir -p /var/ipsec /var/swanctl - # needed by do_postamble - local debug install_routes routing_tables_ignored device_list - config_load ipsec # Generate /var/ipsec/strongswan.conf swan_reset + swan_xappend0 "# generated by /etc/init.d/swanctl" config_foreach config_ipsec ipsec - do_postamble # Generate /var/swanctl/swanctl.conf swanctl_reset