]> git.99rst.org Git - openwrt-packages.git/commitdiff
strongswan: move strongswan.conf generation to its own function
authorFlorian Eckert <redacted>
Thu, 9 Jul 2026 12:05:53 +0000 (14:05 +0200)
committerPhilip Prindeville <redacted>
Thu, 16 Jul 2026 20:27:36 +0000 (14:27 -0600)
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 <redacted>
net/strongswan/files/swanctl.init

index 57def8809843621243e4ab3243bfc3e233e6fa2f..1e8069cb392a67638502ce84760d2decb1b56cc6 100644 (file)
@@ -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
git clone https://git.99rst.org/PROJECT