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
|
# 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
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -119,22 +119,17 @@ error_handler() {
|
|||||||
tail -n 20 "$SILENT_LOGFILE"
|
tail -n 20 "$SILENT_LOGFILE"
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
|
|
||||||
if [[ -n "${CTID:-}" ]]; then
|
# Copy log to container home for later retrieval (if running inside container via pct exec)
|
||||||
local HOST_LOG="/tmp/install-$(date +%Y%m%d_%H%M%S)_${SESSION_ID:-error}.log"
|
if [[ -d /root ]]; then
|
||||||
if pct push $CTID "$SILENT_LOGFILE" "$HOST_LOG" 2>/dev/null; then
|
local container_log="/root/.install-${SESSION_ID:-error}.log"
|
||||||
if declare -f msg_custom >/dev/null 2>&1; then
|
cp "$SILENT_LOGFILE" "$container_log" 2>/dev/null || true
|
||||||
msg_custom "✓" "${GN}" "Full log saved to host: ${HOST_LOG}"
|
if declare -f msg_custom >/dev/null 2>&1; then
|
||||||
else
|
msg_custom "📋" "${YW}" "Log saved to: ${container_log}"
|
||||||
echo -e "${GN}✓ Full log saved to host:${CL} ${BL}${HOST_LOG}${CL}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if declare -f msg_custom >/dev/null 2>&1; then
|
echo -e "${YW}Log saved to:${CL} ${BL}${container_log}${CL}"
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# Running on host - show local path
|
||||||
if declare -f msg_custom >/dev/null 2>&1; then
|
if declare -f msg_custom >/dev/null 2>&1; then
|
||||||
msg_custom "📋" "${YW}" "Full log: ${SILENT_LOGFILE}"
|
msg_custom "📋" "${YW}" "Full log: ${SILENT_LOGFILE}"
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user