Skip to content

Instantly share code, notes, and snippets.

@Nexarian
Created August 5, 2025 03:12
Show Gist options
  • Save Nexarian/bbbd91d893109d73b21617d1b7b6f004 to your computer and use it in GitHub Desktop.
Save Nexarian/bbbd91d893109d73b21617d1b7b6f004 to your computer and use it in GitHub Desktop.
Wait for lans
#!/usr/bin/env bash
# Maximum wait time in seconds
timeout=300
elapsed=0
while [[ $elapsed -lt $timeout ]]; do
up0=$(cat /sys/class/net/wlan0/operstate 2>/dev/null)
up1=$(cat /sys/class/net/wlan1/operstate 2>/dev/null)
if [[ "$up0" == "up" && "$up1" == "up" ]]; then
echo "[wait-for-wlans] wlan0 and wlan1 are up"
exit 0
fi
echo "[wait-for-wlans] Waiting for wlan0/wlan1..."
sleep 2
elapsed=$((elapsed + 2))
done
echo "[wait-for-wlans] Timeout waiting for wlan0 and wlan1"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment