fix(setup-network): bounce interface and force DHCP renew after AP switch to restore connectivity

This commit is contained in:
Justin Oros
2026-04-23 11:43:39 -07:00
parent ff5cb104f8
commit 337d238d7f

View File

@@ -170,6 +170,31 @@ case "$NET_OPT" in
wpa_cli -i "$WIFI_IFACE" save_config >/dev/null 2>&1 || true
info "Associated — renewing DHCP lease..."
ip link set "$WIFI_IFACE" down 2>/dev/null || true
sleep 1
ip link set "$WIFI_IFACE" up 2>/dev/null || true
sleep 1
if systemctl is-active --quiet "systemd-networkd"; then
networkctl reconfigure "$WIFI_IFACE" 2>/dev/null || true
fi
if command -v dhclient >/dev/null 2>&1; then
dhclient -r "$WIFI_IFACE" 2>/dev/null || true
dhclient "$WIFI_IFACE" 2>/dev/null || true
elif command -v udhcpc >/dev/null 2>&1; then
udhcpc -i "$WIFI_IFACE" -q 2>/dev/null || true
fi
sleep 3
NEW_IP=$(ip -o -4 addr show "$WIFI_IFACE" 2>/dev/null | awk '{print $4}' | head -1)
if [ -n "$NEW_IP" ]; then
info "IP address: ${NEW_IP}"
else
warn "No IP assigned yet — DHCP may still be in progress."
fi
NETPLAN_FILE=$(ls /etc/netplan/*.yaml 2>/dev/null | head -1)
if [ -n "$NETPLAN_FILE" ] && grep -q "access-points" "$NETPLAN_FILE" 2>/dev/null; then
warn "Updating netplan config with new WiFi credentials..."