From bf88111289707ea799cc8e80b11c2e4919c2dea8 Mon Sep 17 00:00:00 2001 From: Andrei Smaliak Date: Mon, 14 Sep 2026 11:36:59 +0200 Subject: [PATCH] Validate live broker without a second daemon and correct self-test journal counts --- .../iomatex-postinstall-selftest.sh | 22 ++++++++----------- stage_z2m/stage_z2m.sh | 10 ++++----- stage_z2m/stage_z2m_05_deps.sh | 5 +---- stage_z2m/stage_z2m_06_build.sh | 5 +---- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/stage_validation/iomatex-postinstall-selftest.sh b/stage_validation/iomatex-postinstall-selftest.sh index d1c4544..6c2ed96 100755 --- a/stage_validation/iomatex-postinstall-selftest.sh +++ b/stage_validation/iomatex-postinstall-selftest.sh @@ -165,7 +165,7 @@ check_base_system() { fi local journal_err_count="" - journal_err_count="$(journalctl -p 3 -xb --no-pager 2>/dev/null | wc -l | tr -d ' ')" + journal_err_count="$(journalctl -q -o json -p 3 -b --no-pager 2>/dev/null | wc -l | tr -d ' ')" if [[ -n "$journal_err_count" ]]; then if [[ "$journal_err_count" -eq 0 ]]; then pass "no priority<=3 entries in current boot journal" @@ -322,16 +322,8 @@ check_mqtt() { fail "mosquitto config missing" fi - if have_cmd mosquitto; then - if run_quick "mosquitto -c /etc/mosquitto/mosquitto.conf -p 0 -d >/dev/null" 5; then - pass "mosquitto config accepted by daemon" - else - warn "mosquitto config validation by daemon failed" - fi - else - warn "mosquitto binary not available for config validation" - fi - + # Do not start a second daemon against the live broker's listeners/persistence. + # The running service and the real pub/sub round trip below validate runtime. if have_cmd mosquitto_pub && have_cmd mosquitto_sub; then local topic="iomatex/selftest/${HOSTNAME_SHORT}/$$" local payload="ping-$(date +%s)" @@ -422,7 +414,11 @@ check_cockpit() { fi if unit_exists "cockpit.service"; then - unit_active "cockpit.service" && pass "cockpit.service active" || warn "cockpit.service installed but inactive" + if unit_active "cockpit.service" || unit_active "cockpit.socket"; then + pass "cockpit service active or available through its socket" + else + warn "cockpit service and socket inactive" + fi else warn "cockpit.service not installed" fi @@ -560,7 +556,7 @@ check_logs() { for unit in iomatex-console.service mosquitto.service zigbee2mqtt.service iomatex-ap-watch.service iomatex-wifi-dstate-watchdog.service itscreen-x11.service; do if unit_exists "$unit"; then local err_count="" - err_count="$(journalctl -u "$unit" -p err --since '24 hours ago' --no-pager 2>/dev/null | wc -l | tr -d ' ')" + err_count="$(journalctl -q -o json -u "$unit" -p err --since '24 hours ago' --no-pager 2>/dev/null | wc -l | tr -d ' ')" if [[ -n "$err_count" && "$err_count" -gt 0 ]]; then warn "${unit} has ${err_count} error-priority log lines in the last 24h" else diff --git a/stage_z2m/stage_z2m.sh b/stage_z2m/stage_z2m.sh index b248e9f..608d365 100755 --- a/stage_z2m/stage_z2m.sh +++ b/stage_z2m/stage_z2m.sh @@ -3,12 +3,12 @@ set -Eeuo pipefail # IOMATEX Zigbee2MQTT stage orchestrator. # Stages: -# 01_base OS/toolchain bootstrap only +# 01_base install bundled OS packages and Node # 02_user_dirs user, groups, directories, data perms -# 03_code sync bundled Zigbee2MQTT code only (no git on edge) +# 03_code deploy bundled Zigbee2MQTT runtime # 04_config serial detect + safe configuration.yaml patch/create # 05_deps verify bundled native dependencies -# 06_build isolated tsc + writehash only +# 06_build verify prebuilt dist and write hash # 07_runtime wrapper, systemd units, web proxy, help command # 08_enable enable/restart services + summary # Manual usage: @@ -17,10 +17,10 @@ set -Eeuo pipefail # sudo bash stage_z2m.sh 06_build # sudo bash stage_z2m.sh from 05_deps # sudo bash stage_z2m.sh to 04_config -# Build problem diagnostics: +# Runtime integrity diagnostics: # Run 01_base, 03_code, 05_deps, 06_build in sequence. # Bundle layout for 03_code: -# place Zigbee2MQTT source as ./zigbee2mqtt/ or ./zigbee2mqtt.tar.gz next to this script. +# third_party/zigbee2mqtt contains the prebuilt arm64 runtime and dependencies. SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=./stage_z2m_lib.sh diff --git a/stage_z2m/stage_z2m_05_deps.sh b/stage_z2m/stage_z2m_05_deps.sh index b2cf832..46d23de 100755 --- a/stage_z2m/stage_z2m_05_deps.sh +++ b/stage_z2m/stage_z2m_05_deps.sh @@ -10,10 +10,7 @@ main() { stage_init "05" "deps" require_cmd sudo node - step "Dependency install preflight" - log "Detailed dependency log: ${PNPM_INSTALL_LOG}" - - step "Install dependencies only" + step "Verify bundled native dependencies" install_dependencies } diff --git a/stage_z2m/stage_z2m_06_build.sh b/stage_z2m/stage_z2m_06_build.sh index dcde45e..c6f783b 100755 --- a/stage_z2m/stage_z2m_06_build.sh +++ b/stage_z2m/stage_z2m_06_build.sh @@ -10,10 +10,7 @@ main() { stage_init "06" "build" require_cmd sudo node - step "Build preflight" - log "Detailed build logs: ${TSC_LOG} and ${WRITEHASH_LOG}" - - step "Run isolated build" + step "Verify bundled dist and write runtime hash" build_z2m }