fix: enhance AP and client mode switching with NetworkManager support

This commit is contained in:
Timothy Hofland
2026-03-16 08:50:26 +01:00
parent 4ad82a1a66
commit 12ff47207e
3 changed files with 100 additions and 17 deletions

View File

@ -4,12 +4,16 @@ set -euo pipefail
echo "Switching to client mode..."
systemctl stop mpvj-ap-mode.service 2>/dev/null || true
systemctl stop hostapd.service dnsmasq.service
ip addr flush dev wlan0 || true
ip link set wlan0 up || true
systemctl start wpa_supplicant.service || systemctl start wpa_supplicant@wlan0.service
if command -v nmcli > /dev/null 2>&1 && nmcli connection show MPVJ-AP > /dev/null 2>&1; then
nmcli connection down MPVJ-AP 2>/dev/null || true
nmcli device set wlan0 autoconnect yes || true
nmcli device connect wlan0 2>/dev/null || true
else
systemctl stop mpvj-ap-mode.service 2>/dev/null || true
systemctl stop hostapd.service dnsmasq.service
ip addr flush dev wlan0 || true
ip link set wlan0 up || true
systemctl start wpa_supplicant.service || systemctl start wpa_supplicant@wlan0.service
fi
echo "Client mode active. wlan0 returned to wpa_supplicant."