summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-06-17 11:29:02 +0200
committerSimon Rettberg2022-06-17 11:29:02 +0200
commit094ce8ac86231e47929effc494bbe715a638469f (patch)
tree1dd7d6edc8c85a34c16992fb36355cf1cf7866fe
parent[*] Redirect 'set -x' output exclusively to /run/openslx/* (diff)
downloadsystemd-init-094ce8ac86231e47929effc494bbe715a638469f.tar.gz
systemd-init-094ce8ac86231e47929effc494bbe715a638469f.tar.xz
systemd-init-094ce8ac86231e47929effc494bbe715a638469f.zip
[slx-network] Handle renew in trigger script; shellcheck improvements
-rwxr-xr-xmodules.d/slx-network/scripts/udhcpc-trigger.stage313
1 files changed, 6 insertions, 7 deletions
diff --git a/modules.d/slx-network/scripts/udhcpc-trigger.stage3 b/modules.d/slx-network/scripts/udhcpc-trigger.stage3
index 6649bf36..3c3d09ba 100755
--- a/modules.d/slx-network/scripts/udhcpc-trigger.stage3
+++ b/modules.d/slx-network/scripts/udhcpc-trigger.stage3
@@ -14,8 +14,8 @@ MAIN_NETIF="$SLX_PXE_NETIF"
[ -n "$SLX_BRIDGE" ] && MAIN_NETIF="$SLX_BRIDGE"
readonly MAIN_NETIF
-if [ "x$1" != "xbound" -a "x$1" != "xrenew" ] \
- || [ "x$interface" != "x${MAIN_NETIF}" ] \
+if [[ "$1" != "bound" && "$1" != "renew" ]] \
+ || [ "$interface" != "${MAIN_NETIF}" ] \
|| [ -z "$ip" ]; then
exit 0
fi
@@ -36,13 +36,14 @@ if [ -n "$SLX_PXE_CLIENT_IP" ]; then
# remove default route and let it be added again below, as it might get lost when changing the primary address on the interface
ip route del default 2>/dev/null
ip addr del "$SLX_PXE_CLIENT_IP" dev "${interface}" 2>/dev/null
- ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}"
- echo "SLX_DHCP_CLIENT_IP='$ip'" >> "$NETWORK_CONF"
fi
else
#...no address configured yet, just add...
echo "..adding ${ip}.."
+fi
+if ! ip addr show dev "${interface}" | grep -qF "inet ${ip}/"; then
ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}"
+ echo "SLX_DHCP_CLIENT_IP='$ip'" >> "$NETWORK_CONF"
fi
# Same procedure for default gateway
@@ -50,10 +51,8 @@ if [ -n "$router" ]; then
if [ -n "$SLX_PXE_GATEWAY" ] && [ "$SLX_PXE_GATEWAY" != "$router" ]; then
echo "..reconfiguring default gw from '$SLX_PXE_GATEWAY' to '$router'."
ip route del default 2>/dev/null
- ip route add default via "$router"
- else
- ip route add default via "$router"
fi
+ ip route add default via "$router"
echo "SLX_DHCP_GATEWAY='$router'" >> "$NETWORK_CONF"
fi