Update build.func
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled

This commit is contained in:
CanbiZ 2025-09-22 14:51:52 +02:00
parent 176f86de5d
commit 8dec778dff

View File

@ -2301,18 +2301,37 @@ EOF'
} }
destroy_lxc() { destroy_lxc() {
if [[ -n "$CT_ID" ]]; then if [[ -z "$CT_ID" ]]; then
read -p "Remove this Container? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
pct stop "$CT_ID" &>/dev/null
pct destroy "$CT_ID" &>/dev/null
msg_ok "Removed this Container"
else
msg_info "Container was not removed."
fi
else
msg_error "No CT_ID found. Nothing to remove." msg_error "No CT_ID found. Nothing to remove."
return 1
fi fi
# Abbruch bei Ctrl-C / Ctrl-D / ESC
trap 'echo; msg_error "Aborted by user (SIGINT/SIGQUIT)"; return 130' INT QUIT
local prompt
if ! read -rp "Remove this Container? <y/N> " prompt; then
# read gibt != 0 zurück bei Ctrl-D/ESC
msg_error "Aborted input (Ctrl-D/ESC)"
return 130
fi
case "${prompt,,}" in
y | yes)
if pct stop "$CT_ID" &>/dev/null && pct destroy "$CT_ID" &>/dev/null; then
msg_ok "Removed Container $CT_ID"
else
msg_error "Failed to remove Container $CT_ID"
return 1
fi
;;
"" | n | no)
msg_info "Container was not removed."
;;
*)
msg_warn "Invalid response. Container was not removed."
;;
esac
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------