fix: refactor networking scripts for improved robustness and clarity
This commit is contained in:
@ -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."
|
||||
|
||||
Reference in New Issue
Block a user