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.
This commit is contained in:
parent
dd34f2d8b3
commit
27bb9e5192
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
# 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 "✓" "${GN}" "Full log saved to host: ${HOST_LOG}"
|
||||
msg_custom "📋" "${YW}" "Log saved to: ${container_log}"
|
||||
else
|
||||
echo -e "${GN}✓ Full log saved to host:${CL} ${BL}${HOST_LOG}${CL}"
|
||||
fi
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user