refactor(preflight): move to install_script, clean UX flow

- Move run_preflight from build_container() into install_script() after header_info
- Shows: Header → preflight checks → 2s pause → clear (via next header_info call)
- On failure: show summary + exit cleanly (no ERR trap)
- Change all return 1 → return 0 in preflight functions (prevents ERR trap under set -Ee)
- Remove PREFLIGHT_DONE guard from build_container (no longer needed)
This commit is contained in:
CanbiZ (MickLesk)
2026-03-03 14:10:03 +01:00
parent 4254e15bba
commit d242100531

View File

@@ -540,9 +540,9 @@ preflight_template_available() {
# #
# - Executes all preflight checks and collects results # - Executes all preflight checks and collects results
# - Displays a summary with pass/fail/warn counts # - Displays a summary with pass/fail/warn counts
# - On failure: reports to telemetry with "aborted" status and exits # - On failure: reports to telemetry with "aborted" status and exits cleanly
# - On success: continues with brief confirmation # - On success: brief pause (2s) then returns (caller shows next screen)
# - Called from install_script() after diagnostics_check() # - Called from install_script() after header_info()
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
run_preflight() { run_preflight() {
# Reset counters # Reset counters
@@ -599,13 +599,13 @@ run_preflight() {
exit "$PREFLIGHT_EXIT_CODE" exit "$PREFLIGHT_EXIT_CODE"
fi fi
# Success # Success — brief pause so user can see results, then clear for next screen
if [[ "$PREFLIGHT_WARNINGS" -gt 0 ]]; then if [[ "$PREFLIGHT_WARNINGS" -gt 0 ]]; then
echo -e "${CM}${BOLD}${GN} Pre-flight passed with ${PREFLIGHT_WARNINGS} warning(s) (${PREFLIGHT_PASSED} checks passed)${CL}" echo -e "${CM}${BOLD}${GN} Pre-flight passed with ${PREFLIGHT_WARNINGS} warning(s) (${PREFLIGHT_PASSED} checks passed)${CL}"
else else
echo -e "${CM}${BOLD}${GN} All pre-flight checks passed (${PREFLIGHT_PASSED}/${PREFLIGHT_PASSED})${CL}" echo -e "${CM}${BOLD}${GN} All pre-flight checks passed (${PREFLIGHT_PASSED}/${PREFLIGHT_PASSED})${CL}"
fi fi
echo "" sleep 2
} }
# ============================================================================== # ==============================================================================
@@ -3461,8 +3461,9 @@ install_script() {
fi fi
[[ "${timezone:-}" == Etc/* ]] && timezone="host" # pct doesn't accept Etc/* zones [[ "${timezone:-}" == Etc/* ]] && timezone="host" # pct doesn't accept Etc/* zones
# Show APP Header # Show APP Header + run preflight checks
header_info header_info
run_preflight
# --- Support CLI argument as direct preset (default, advanced, …) --- # --- Support CLI argument as direct preset (default, advanced, …) ---
CHOICE="${mode:-${1:-}}" CHOICE="${mode:-${1:-}}"
@@ -3992,12 +3993,6 @@ start() {
build_container() { build_container() {
# if [ "$VERBOSE" == "yes" ]; then set -x; fi # if [ "$VERBOSE" == "yes" ]; then set -x; fi
# Run preflight checks once (skipped on recursive retry calls)
if [[ "${PREFLIGHT_DONE:-}" != "true" ]]; then
run_preflight
PREFLIGHT_DONE=true
fi
NET_STRING="-net0 name=eth0,bridge=${BRG:-vmbr0}" NET_STRING="-net0 name=eth0,bridge=${BRG:-vmbr0}"
# MAC # MAC