From 27bb9e519236a3693bb0884023d4c4b9c178b79c Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 4 Nov 2025 17:10:28 +0100 Subject: [PATCH] Improve install log handling for containers Enhances the build and error handler scripts to better manage installation logs. On install failure, the log is now copied from the container to the host for easier debugging. The error handler now saves the log inside the container's /root directory for later retrieval, improving traceability and support. --- misc/build.func | 7 ++++++- misc/error_handler.func | 21 ++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/misc/build.func b/misc/build.func index a2270e845..29e18d9ef 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2518,7 +2518,12 @@ EOF' # Run application installer if ! lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)"; then - exit $? + local exit_code=$? + # Try to copy installation log from container before exiting + if [[ -n "$CTID" && -n "${SESSION_ID:-}" ]]; then + pct pull "$CTID" "/root/.install-${SESSION_ID}.log" "/tmp/install-${SESSION_ID}.log" 2>/dev/null || true + fi + exit $exit_code fi } diff --git a/misc/error_handler.func b/misc/error_handler.func index 2599d59b0..5aa38e5e1 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -119,22 +119,17 @@ error_handler() { tail -n 20 "$SILENT_LOGFILE" echo "-----------------------------------" - if [[ -n "${CTID:-}" ]]; then - local HOST_LOG="/tmp/install-$(date +%Y%m%d_%H%M%S)_${SESSION_ID:-error}.log" - if pct push $CTID "$SILENT_LOGFILE" "$HOST_LOG" 2>/dev/null; then - if declare -f msg_custom >/dev/null 2>&1; then - msg_custom "✓" "${GN}" "Full log saved to host: ${HOST_LOG}" - else - echo -e "${GN}✓ Full log saved to host:${CL} ${BL}${HOST_LOG}${CL}" - fi + # Copy log to container home for later retrieval (if running inside container via pct exec) + if [[ -d /root ]]; then + local container_log="/root/.install-${SESSION_ID:-error}.log" + cp "$SILENT_LOGFILE" "$container_log" 2>/dev/null || true + if declare -f msg_custom >/dev/null 2>&1; then + msg_custom "📋" "${YW}" "Log saved to: ${container_log}" else - if declare -f msg_custom >/dev/null 2>&1; then - msg_custom "📋" "${YW}" "Full log path in container: ${SILENT_LOGFILE}" - else - echo -e "${YW}Full log path in container:${CL} ${BL}${SILENT_LOGFILE}${CL}" - fi + echo -e "${YW}Log saved to:${CL} ${BL}${container_log}${CL}" fi else + # Running on host - show local path if declare -f msg_custom >/dev/null 2>&1; then msg_custom "📋" "${YW}" "Full log: ${SILENT_LOGFILE}" else