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,19 @@
#!/bin/bash
echo "Switching to AP Mode..."
# Stop wpa_supplicant for client mode
systemctl stop wpa_supplicant
set -euo pipefail
# Configure static IP for wlan0 (normally handled by dhcpcd or systemd-networkd)
# ifconfig wlan0 192.168.4.1
echo "Switching to AP mode..."
# Start AP services
systemctl start hostapd
systemctl start dnsmasq
rfkill unblock wlan || true
systemctl stop wpa_supplicant.service wpa_supplicant@wlan0.service 2>/dev/null || true
echo "AP Mode active: MPVJ-3B"
ip link set wlan0 down || true
ip addr flush dev wlan0 || true
ip link set wlan0 up
ip address add 192.168.4.1/24 dev wlan0
systemctl start mpvj-ap-mode.service
systemctl restart hostapd.service
systemctl restart dnsmasq.service
echo "AP mode active on wlan0 at 192.168.4.1"