Compare commits

..

2 Commits

Author SHA1 Message Date
MickLesk fe01d670f6 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.
2026-07-21 23:32:19 +02:00
MickLesk e0df8a80bf Don't destroy container on install-recovery menu read failure
read -t returns >128 on a real timeout, but a lower/plain error code
on a genuine read failure (e.g. broken/closed stdin, I/O error) -
these were treated identically as "no response", so a user whose
keystroke failed to be captured (e.g. a transient stdin I/O error)
got their container silently destroyed instead of kept. Only
auto-remove on an actual timeout; on a hard read failure, keep the
container (reversible) and tell the user how to remove it manually.
2026-07-21 23:27:22 +02:00
4 changed files with 30 additions and 10 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-8}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_version="${var_version:-12}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
-5
View File
@@ -24,11 +24,6 @@ if [[ ! "$CONFIRM" =~ ^([yY][eE][sS]|[yY])$ ]]; then
exit 10
fi
msg_info "Switching SSH to classic (non-socket-activated) mode"
systemctl disable --now ssh.socket &>/dev/null || true
systemctl enable --now ssh &>/dev/null || true
msg_ok "Switched SSH to classic mode"
msg_info "Installing NextCloudPi (Patience)"
$STD bash <(curl -fsSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh)
msg_ok "Installed NextCloudPi"
+12 -2
View File
@@ -5140,7 +5140,10 @@ EOF
echo -en "${YW}Select option [1-${max_option}] (default: 1, auto-remove in 60s): ${CL}"
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
case "${response:-1}" in
1)
# Remove container
@@ -5359,13 +5362,20 @@ EOF
fi
;;
esac
else
elif [[ $read_rc -gt 128 ]]; then
# Timeout - auto-remove
echo ""
msg_info "No response - removing container ${CTID}"
pct stop "$CTID" &>/dev/null || true
pct destroy "$CTID" &>/dev/null || true
msg_ok "Container ${CTID} removed"
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 ""
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}"
fi
# Force one final status update attempt after cleanup
+17 -2
View File
@@ -497,7 +497,10 @@ error_handler() {
fi
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
echo ""
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}"
fi
fi
else
elif [[ $read_rc -gt 128 ]]; then
# Timeout - auto-remove
echo ""
if declare -f msg_info >/dev/null 2>&1; then
@@ -535,6 +538,18 @@ error_handler() {
else
echo -e "${GN}${CL} Container ${CTID} removed"
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