fix: refactor networking scripts for improved robustness and clarity

This commit is contained in:
Timothy Hofland
2026-03-16 08:42:26 +01:00
parent 855339ef42
commit 4ad82a1a66
4 changed files with 167 additions and 83 deletions

View File

@ -1,14 +1,15 @@
#!/bin/bash
echo "Switching to Client Mode..."
# Stop AP services
systemctl stop hostapd
systemctl stop dnsmasq
set -euo pipefail
# Start wpa_supplicant
systemctl start wpa_supplicant
echo "Switching to client mode..."
# Normally would trigger a re-scan or wait for IP
# dhclient wlan0
systemctl stop mpvj-ap-mode.service 2>/dev/null || true
systemctl stop hostapd.service dnsmasq.service
echo "Client Mode active. Connecting to configured SSID..."
ip addr flush dev wlan0 || true
ip link set wlan0 up || true
systemctl start wpa_supplicant.service || systemctl start wpa_supplicant@wlan0.service
echo "Client mode active. wlan0 returned to wpa_supplicant."