ipsec-interfaces: Move conditional block into the loop

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2019-01-22 11:26:32 +00:00
parent 38f6bdb740
commit d985ce5ae9

View 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}"