mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-21 20:05:48 +02:00
Don't destroy container on error_handler recovery-prompt read failure
Same bug as build.func's install-recovery menu: this "Remove broken container?" prompt treated a hard read failure (broken/closed stdin, I/O error) identically to a real 60s timeout, defaulting to pct destroy either way. Only auto-remove on an actual timeout (read_rc > 128); on a genuine read failure, keep the container instead of guessing and destroying it.
This commit is contained in:
+17
-2
@@ -497,7 +497,10 @@ error_handler() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local response=""
|
local response=""
|
||||||
if read -t 60 -r response; then
|
local read_rc
|
||||||
|
read -t 60 -r response
|
||||||
|
read_rc=$?
|
||||||
|
if [[ $read_rc -eq 0 ]]; then
|
||||||
if [[ -z "$response" || "$response" =~ ^[Yy]$ ]]; then
|
if [[ -z "$response" || "$response" =~ ^[Yy]$ ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
if declare -f msg_info >/dev/null 2>&1; then
|
if declare -f msg_info >/dev/null 2>&1; then
|
||||||
@@ -520,7 +523,7 @@ error_handler() {
|
|||||||
echo -e "${YW}Container ${CTID} kept for debugging${CL}"
|
echo -e "${YW}Container ${CTID} kept for debugging${CL}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
elif [[ $read_rc -gt 128 ]]; then
|
||||||
# Timeout - auto-remove
|
# Timeout - auto-remove
|
||||||
echo ""
|
echo ""
|
||||||
if declare -f msg_info >/dev/null 2>&1; then
|
if declare -f msg_info >/dev/null 2>&1; then
|
||||||
@@ -535,6 +538,18 @@ error_handler() {
|
|||||||
else
|
else
|
||||||
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# read itself failed (e.g. broken/closed stdin, I/O error) rather than
|
||||||
|
# timing out - don't guess and destroy the container on a read we
|
||||||
|
# couldn't actually capture; keep it since that's the reversible choice.
|
||||||
|
echo ""
|
||||||
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
|
msg_error "Could not read your response (stdin error) - keeping container ${CTID} for safety."
|
||||||
|
msg_error "Remove it manually if not needed: pct destroy ${CTID}"
|
||||||
|
else
|
||||||
|
echo -e "${YW}Could not read your response (stdin error) - keeping container ${CTID} for safety.${CL}"
|
||||||
|
echo -e "${YW}Remove it manually if not needed: pct destroy ${CTID}${CL}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user