fix: force NetworkManager hotspot priority and disconnect active client wifi to ensure AP activation

This commit is contained in:
Timothy Hofland
2026-03-15 23:56:38 +01:00
parent 237ff76670
commit 6fea68f903

View File

@ -142,6 +142,9 @@ rfkill unblock wlan || true
if command -v nmcli > /dev/null; then if command -v nmcli > /dev/null; then
echo "NetworkManager detected. Using nmcli for hotspot..." echo "NetworkManager detected. Using nmcli for hotspot..."
# Disconnect current wifi to free the radio
nmcli device disconnect wlan0 2>/dev/null || true
# Clean up any existing MPVJ connection # Clean up any existing MPVJ connection
nmcli con delete MPVJ-AP 2>/dev/null || true nmcli con delete MPVJ-AP 2>/dev/null || true
@ -151,8 +154,12 @@ if command -v nmcli > /dev/null; then
nmcli con modify MPVJ-AP wifi-sec.key-mgmt wpa-psk nmcli con modify MPVJ-AP wifi-sec.key-mgmt wpa-psk
nmcli con modify MPVJ-AP wifi-sec.psk "$WIFI_PASS" nmcli con modify MPVJ-AP wifi-sec.psk "$WIFI_PASS"
nmcli con modify MPVJ-AP ipv4.addresses 192.168.4.1/24 nmcli con modify MPVJ-AP ipv4.addresses 192.168.4.1/24
nmcli con modify MPVJ-AP connection.autoconnect-priority 100
# Ensure hostapd/dnsmasq are disabled to prevent conflict # Bring it up immediately
nmcli con up MPVJ-AP || true
# Ensure hostapd/dnsmasq are disabled
systemctl stop hostapd dnsmasq 2>/dev/null || true systemctl stop hostapd dnsmasq 2>/dev/null || true
systemctl disable hostapd dnsmasq 2>/dev/null || true systemctl disable hostapd dnsmasq 2>/dev/null || true
systemctl mask hostapd dnsmasq 2>/dev/null || true systemctl mask hostapd dnsmasq 2>/dev/null || true