From 1caa09ac4656643d4f7c731b530622f34be6d227 Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Sat, 30 Aug 2025 21:51:03 +0100 Subject: [PATCH] added delay in process --- setup.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 9346bcf..4dcbbe7 100644 --- a/setup.sh +++ b/setup.sh @@ -271,12 +271,27 @@ FirewallRuleSet preauthenticated-users { RedirectURL http://10.0.252.1/static/index.html EOF -# Restart services +# Restart services in the correct order and add delays to prevent race conditions +echo "Restarting services..." sudo systemctl restart dhcpcd -sudo systemctl restart dnsmasq sudo systemctl restart hostapd -if command -v nodogsplash &> /dev/null; then - sudo systemctl restart nodogsplash + +# Wait for the interface to come up and get the IP address +echo "Waiting for wlan0 to be configured..." +sleep 5 # Give services a moment to start + +# Check for the IP address before starting nodogsplash +IP_CHECK=$(ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') +if [ "$IP_CHECK" == "10.0.252.1" ]; then + echo "✅ wlan0 configured with IP $IP_CHECK." + sudo systemctl restart dnsmasq + if command -v nodogsplash &> /dev/null; then + sudo systemctl restart nodogsplash + fi +else + echo "❌ Error: wlan0 failed to get the static IP 10.0.252.1. Found: '$IP_CHECK'." + echo "Please check 'sudo systemctl status hostapd' and 'sudo systemctl status dhcpcd'." + exit 1 fi echo "✅ WiFi hotspot and captive portal configured. SSID: TimeTurner, IP: 10.0.252.1"