]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ipsec-interfaces: Move conditional block into the loop
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Jan 2019 11:26:32 +0000 (11:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Feb 2019 18:20:36 +0000 (18:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/ipsec-interfaces

index d73eef9b0849c97f67b5a9d7b9ff8138e4f18eba..c137a77b997c88101883db581c1cbae05c5ba832 100644 (file)
@@ -44,25 +44,6 @@ main() {
 
        local interfaces=()
 
-       # Compat for older connections
-       if [ "${local}" = "off" ]; then
-               if [ "${VPN_IP}" = "%defaultroute" ]; then
-                       local=""
-               else
-                       local="${VPN_IP}"
-               fi
-       fi
-
-       # Handle %defaultroute
-       if [ -z "${local}" ]; then
-               if [ -r "/var/ipfire/red/local-ipaddress" ]; then
-                       local="$(</var/ipfire/red/local-ipaddress)"
-
-               elif [ "${RED_TYPE}" = "STATIC" -a -n "${RED_ADDRESS}" ]; then
-                       local="${RED_ADDRESS}"
-               fi
-       fi
-
        # We are done when IPsec is not enabled
        if [ "${ENABLED}" = "on" ]; then
                while IFS="," read -r "${VARS[@]}"; do
@@ -85,6 +66,25 @@ main() {
                        # Add the interface to the list of all interfaces
                        interfaces+=( "${intf}" )
 
+                       # Compat for older connections
+                       if [ "${local}" = "off" ]; then
+                               if [ "${VPN_IP}" = "%defaultroute" ]; then
+                                       local=""
+                               else
+                                       local="${VPN_IP}"
+                               fi
+                       fi
+
+                       # Handle %defaultroute
+                       if [ -z "${local}" ]; then
+                               if [ -r "/var/ipfire/red/local-ipaddress" ]; then
+                                       local="$(</var/ipfire/red/local-ipaddress)"
+
+                               elif [ "${RED_TYPE}" = "STATIC" -a -n "${RED_ADDRESS}" ]; then
+                                       local="${RED_ADDRESS}"
+                               fi
+                       fi
+
                        local args=(
                                "local" "${local}"
                                "remote" "${remote}"