Validate live broker without a second daemon and correct self-test journal counts

This commit is contained in:
Andrei Smaliak 2026-09-14 11:36:59 +02:00
parent 42bac405bc
commit bf88111289
4 changed files with 16 additions and 26 deletions

View File

@ -165,7 +165,7 @@ check_base_system() {
fi fi
local journal_err_count="" 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 [[ -n "$journal_err_count" ]]; then
if [[ "$journal_err_count" -eq 0 ]]; then if [[ "$journal_err_count" -eq 0 ]]; then
pass "no priority<=3 entries in current boot journal" pass "no priority<=3 entries in current boot journal"
@ -322,16 +322,8 @@ check_mqtt() {
fail "mosquitto config missing" fail "mosquitto config missing"
fi fi
if have_cmd mosquitto; then # Do not start a second daemon against the live broker's listeners/persistence.
if run_quick "mosquitto -c /etc/mosquitto/mosquitto.conf -p 0 -d >/dev/null" 5; then # The running service and the real pub/sub round trip below validate runtime.
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
if have_cmd mosquitto_pub && have_cmd mosquitto_sub; then if have_cmd mosquitto_pub && have_cmd mosquitto_sub; then
local topic="iomatex/selftest/${HOSTNAME_SHORT}/$$" local topic="iomatex/selftest/${HOSTNAME_SHORT}/$$"
local payload="ping-$(date +%s)" local payload="ping-$(date +%s)"
@ -422,7 +414,11 @@ check_cockpit() {
fi fi
if unit_exists "cockpit.service"; then 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 else
warn "cockpit.service not installed" warn "cockpit.service not installed"
fi 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 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 if unit_exists "$unit"; then
local err_count="" 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 if [[ -n "$err_count" && "$err_count" -gt 0 ]]; then
warn "${unit} has ${err_count} error-priority log lines in the last 24h" warn "${unit} has ${err_count} error-priority log lines in the last 24h"
else else

View File

@ -3,12 +3,12 @@ set -Eeuo pipefail
# IOMATEX Zigbee2MQTT stage orchestrator. # IOMATEX Zigbee2MQTT stage orchestrator.
# Stages: # Stages:
# 01_base OS/toolchain bootstrap only # 01_base install bundled OS packages and Node
# 02_user_dirs user, groups, directories, data perms # 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 # 04_config serial detect + safe configuration.yaml patch/create
# 05_deps verify bundled native dependencies # 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 # 07_runtime wrapper, systemd units, web proxy, help command
# 08_enable enable/restart services + summary # 08_enable enable/restart services + summary
# Manual usage: # Manual usage:
@ -17,10 +17,10 @@ set -Eeuo pipefail
# sudo bash stage_z2m.sh 06_build # sudo bash stage_z2m.sh 06_build
# sudo bash stage_z2m.sh from 05_deps # sudo bash stage_z2m.sh from 05_deps
# sudo bash stage_z2m.sh to 04_config # 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. # Run 01_base, 03_code, 05_deps, 06_build in sequence.
# Bundle layout for 03_code: # 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)" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./stage_z2m_lib.sh # shellcheck source=./stage_z2m_lib.sh

View File

@ -10,10 +10,7 @@ main() {
stage_init "05" "deps" stage_init "05" "deps"
require_cmd sudo node require_cmd sudo node
step "Dependency install preflight" step "Verify bundled native dependencies"
log "Detailed dependency log: ${PNPM_INSTALL_LOG}"
step "Install dependencies only"
install_dependencies install_dependencies
} }

View File

@ -10,10 +10,7 @@ main() {
stage_init "06" "build" stage_init "06" "build"
require_cmd sudo node require_cmd sudo node
step "Build preflight" step "Verify bundled dist and write runtime hash"
log "Detailed build logs: ${TSC_LOG} and ${WRITEHASH_LOG}"
step "Run isolated build"
build_z2m build_z2m
} }