All checks were successful
lint / ruff (push) Successful in 45s
Adds a stdlib-only loader (src/lib/env.py) that walks up to find the nearest .env. display.py and notebooks/_helpers.py now `require()` the config values; wifi-check.sh sources .env to derive its probe host. The .env file is gitignored; .env.example documents the required keys. The existing tokens are still present in git history and will be scrubbed in the next commit; rotate them after the rewrite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.1 KiB
Shell
Executable file
44 lines
1.1 KiB
Shell
Executable file
#!/bin/bash
|
|
# Probe what actually matters (DNS to a real target) and escalate recovery
|
|
# steps until something works. `ip link down/up` alone can't unwedge the
|
|
# brcmfmac chip on the Pi Zero 2W.
|
|
|
|
CONNECTION="netplan-wlan0-HiddenPlace"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
# shellcheck disable=SC1091
|
|
[ -f "$SCRIPT_DIR/.env" ] && set -a && . "$SCRIPT_DIR/.env" && set +a
|
|
PROBE_HOST="${HA_URL#http*://}"
|
|
PROBE_HOST="${PROBE_HOST%%/*}"
|
|
: "${PROBE_HOST:?HA_URL must be set in .env}"
|
|
|
|
probe() {
|
|
ping -c 1 -W 5 192.168.0.1 >/dev/null 2>&1 \
|
|
&& getent hosts "$PROBE_HOST" >/dev/null 2>&1
|
|
}
|
|
|
|
probe && exit 0
|
|
|
|
logger "wifi-check: probe failed, reconnecting via nmcli"
|
|
nmcli device disconnect wlan0
|
|
sleep 2
|
|
nmcli connection up "$CONNECTION"
|
|
sleep 10
|
|
probe && exit 0
|
|
|
|
logger "wifi-check: nmcli failed, cycling rfkill"
|
|
rfkill block wifi
|
|
sleep 3
|
|
rfkill unblock wifi
|
|
sleep 15
|
|
probe && exit 0
|
|
|
|
logger "wifi-check: rfkill failed, reloading brcmfmac"
|
|
modprobe -r brcmfmac brcmutil
|
|
sleep 3
|
|
modprobe brcmfmac
|
|
sleep 20
|
|
probe && exit 0
|
|
|
|
logger "wifi-check: all recovery failed, rebooting"
|
|
/sbin/reboot
|