From 4e2b64524fcf623226faaa31260146941a1314a8 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 24 Feb 2026 09:41:40 +0100 Subject: [PATCH] merge vmcore --- misc/vm-core.func | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/misc/vm-core.func b/misc/vm-core.func index e9679e26..f40576de 100644 --- a/misc/vm-core.func +++ b/misc/vm-core.func @@ -169,7 +169,7 @@ get_active_logfile() { # silent() # # - Executes command with output redirected to active log file -# - On error: displays last 10 lines of log and exits with original exit code +# - On error: displays last 20 lines of log and exits with original exit code # - Temporarily disables error trap to capture exit code correctly # - Sources explain_exit_code() for detailed error messages # ------------------------------------------------------------------------------ @@ -207,15 +207,9 @@ silent() { msg_custom "→" "${YWB}" "${cmd}" if [[ -s "$logfile" ]]; then - local log_lines=$(wc -l <"$logfile") - echo "--- Last 10 lines of log ---" - tail -n 10 "$logfile" - echo "----------------------------" - - # Show how to view full log if there are more lines - if [[ $log_lines -gt 10 ]]; then - msg_custom "📋" "${YW}" "View full log (${log_lines} lines): ${logfile}" - fi + echo -e "\n${TAB}--- Last 20 lines of log ---" + tail -n 20 "$logfile" + echo -e "${TAB}----------------------------\n" fi exit "$rc" @@ -535,9 +529,21 @@ cleanup_vmid() { } cleanup() { + local exit_code=$? if [[ "$(dirs -p | wc -l)" -gt 1 ]]; then popd >/dev/null || true fi + # Report final telemetry status if post_to_api_vm was called but no update was sent + if [[ "${POST_TO_API_DONE:-}" == "true" && "${POST_UPDATE_DONE:-}" != "true" ]]; then + if declare -f post_update_to_api >/dev/null 2>&1; then + if [[ $exit_code -ne 0 ]]; then + post_update_to_api "failed" "$exit_code" + else + # Exited cleanly but description()/success was never called — shouldn't happen + post_update_to_api "failed" "1" + fi + fi + fi } check_root() {