diff --git a/local_installer.sh b/local_installer.sh index 9ea823d..021f2ce 100755 --- a/local_installer.sh +++ b/local_installer.sh @@ -672,6 +672,51 @@ next_selected_stage_after() { return 1 } +stage_ui_install_is_valid() { + local service_state="" + local required_path="" + + for required_path in \ + /etc/iomatex/console.json \ + /etc/systemd/system/iomatex-console.service \ + /opt/iomatex-console/backend/app.py \ + /opt/iomatex-console/backend/itscreen_registration.py \ + /opt/iomatex-console/backend/modbus_backend.py \ + /opt/iomatex-console/public/index.html \ + /opt/iomatex-console/public/console.i18n.js \ + /opt/iomatex-console/public/console.js \ + /opt/iomatex-console/public/console.css \ + /opt/iomatex-console/providers.d/00_core_services.py; do + if [[ ! -s "$required_path" ]]; then + warn "stage_ui validation failed: required file is missing or empty: ${required_path}" + return 1 + fi + done + + if command -v systemctl >/dev/null 2>&1; then + service_state="$(systemctl is-enabled iomatex-console.service 2>/dev/null || true)" + if [[ "$service_state" == "masked" ]]; then + warn "stage_ui validation failed: iomatex-console.service is masked" + return 1 + fi + fi + + return 0 +} + +stage_install_is_valid() { + local stage="$1" + + case "$stage" in + stage_ui) + stage_ui_install_is_valid + ;; + *) + return 0 + ;; + esac +} + resolve_resume_stage() { local stage local status @@ -689,6 +734,11 @@ resolve_resume_stage() { printf '%s\n' "$stage" return 0 fi + if ! stage_install_is_valid "$stage" >/dev/null; then + set_stage_status "$stage" "stale_invalid" + printf '%s\n' "$stage" + return 0 + fi done return 1 @@ -1234,6 +1284,14 @@ run_stage() { fi fi + if ! stage_install_is_valid "$stage"; then + set_stage_status "$stage" "failed" + set_state_value "LAST_RESULT" "failed" + FAILED_STAGES+=("$stage") + log "FAIL: ${stage} post-install validation failed" + return 1 + fi + set_stage_status "$stage" "success" set_state_value "LAST_RESULT" "success" SUCCESS_STAGES+=("$stage") @@ -1608,9 +1666,14 @@ for stage in "${STAGE_ORDER[@]}"; do fi if [[ -z "$FROM_STAGE" && "$local_status" == "success" ]]; then - log "RESUME: ${stage} already successful, skipping" - SUCCESS_STAGES+=("$stage") - continue + if stage_install_is_valid "$stage"; then + log "RESUME: ${stage} already successful, skipping" + SUCCESS_STAGES+=("$stage") + continue + fi + warn "RESUME: ${stage} was marked successful but validation failed; rerunning" + set_stage_status "$stage" "stale_invalid" + local_status="stale_invalid" fi echo diff --git a/stage_ui/ui_installer.sh b/stage_ui/ui_installer.sh index 0ffd545..de70df8 100644 --- a/stage_ui/ui_installer.sh +++ b/stage_ui/ui_installer.sh @@ -58,8 +58,8 @@ copy_tree() { require_file() { local path="$1" - [ -f "$path" ] || { - echo "ERROR: required file is missing after deploy step: $path" >&2 + [ -s "$path" ] || { + echo "ERROR: required file is missing or empty after deploy step: $path" >&2 exit 1 } } @@ -293,6 +293,9 @@ fav = img.copy() fav.thumbnail((64, 64)) fav.save(fav_out, format="PNG") PY +require_file "$STAGE_PUBLIC_DIR/g-box.png" +require_file "$STAGE_PUBLIC_DIR/logo.png" +require_file "$STAGE_PUBLIC_DIR/favicon.png" step "Install systemd service" prepare_systemd_unit_path "$SERVICE_UNIT_PATH" "$SERVICE_NAME"