From af241339a3464e08d75f1e107a3798c48c737241 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Fri, 18 Sep 2026 17:51:22 -0400 Subject: [PATCH] Add package dependency checks to deploy.sh Check for required packages (hostapd, iw, nftables, dnsmasq, systemd-resolved) at deploy start and fail if any are missing. Also warn about optional packages used by specific components (rsync, mosquitto, gpsd, python3-paho-mqtt, etc.). Missing required packages halt deployment with clear error message. Optional packages generate warnings that are captured in deploy-warnings.json for the router-status MQTT dashboard. This prevents silent failures when the R5C or other hardware doesn't have expected dependencies installed. Co-Authored-By: Claude Haiku 4.5 --- deploy.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/deploy.sh b/deploy.sh index 254f61d..e2e32d3 100755 --- a/deploy.sh +++ b/deploy.sh @@ -46,6 +46,31 @@ fi [ "$(id -u)" = 0 ] || { echo "Run with sudo (writes to /etc, /usr)."; exit 1; } +# Check for essential package dependencies +echo "== dependency check ==" +REQUIRED_PACKAGES=( + hostapd + iw + nftables + dnsmasq + systemd-resolved +) +OPTIONAL_PACKAGES=( + rsync + mosquitto + gpsd + gpsd-clients + python3-paho-mqtt + python3-gps + python3-bleak + mobile-broadband-provider-info + zerotier-one +) +for pkg in "${REQUIRED_PACKAGES[@]}"; do + dpkg -s "$pkg" >/dev/null 2>&1 || { echo "MISSING REQUIRED: $pkg (apt install $pkg)"; exit 1; } +done +# Note: warn() is defined below; we'll check optional packages after it's defined + # Collected below and persisted to WARNINGS_FILE so the Cockpit vanrouter page # can surface deploy-time issues (missing deps, unedited example configs, drift) # without someone having to remember to scroll back through deploy output. @@ -55,6 +80,13 @@ warn() { # warn — prints " -> " (as before) and recor echo " -> $*" WARNINGS+=("$*") } + +# Check optional packages now that warn() is defined +for pkg in "${OPTIONAL_PACKAGES[@]}"; do + if ! dpkg -s "$pkg" >/dev/null 2>&1; then + warn "optional package not installed: $pkg (apt install $pkg)" + fi +done write_warnings() { install -d -m0755 "$(dirname "$WARNINGS_FILE")" {