Allow removing multiple LXC mountpoints

Update `remove_lxc_mountpoint` in `storage-share-helper.sh` to support multi-select mountpoint removal for a container. Each selected mountpoint is now confirmed individually (default No), processed independently, and reported in a final result summary with `removed`, `FAILED`, or `skipped` status.
This commit is contained in:
MickLesk
2026-07-21 09:02:40 +02:00
parent 3531a1f9ee
commit a810413522
+30 -12
View File
@@ -436,26 +436,44 @@ add_lxc_mountpoint() {
remove_lxc_mountpoint() {
header_info
local ctid mp_key mp_def
local ctid selection mp_key mp_def
local -a results=()
ctid=$(pick_container "LXC: remove mountpoint") || return
mp_key=$(pick_mountpoint "$ctid" "LXC: remove mountpoint") || return
mp_def=$(pct config "$ctid" | awk -F': ' -v k="$mp_key" '$1==k{print $2}')
selection=$(pick_mountpoints_multi "$ctid" "LXC: remove mountpoint") || return
if [[ -z "$selection" ]]; then
msg_warn "No mountpoint selected."
pause
return
fi
confirm_danger "LXC: remove mountpoint" \
"Remove ${mp_key} from CT ${ctid}?
# Confirm each selected mountpoint separately (defaults to No).
for mp_key in $selection; do
mp_key="${mp_key//\"/}"
[[ -z "$mp_key" ]] && continue
mp_def=$(pct config "$ctid" | awk -F': ' -v k="$mp_key" '$1==k{print $2}')
if confirm_danger "LXC: remove mountpoint" \
"Remove ${mp_key} from CT ${ctid}?
${mp_key}: ${mp_def}
This only detaches the mountpoint from the container.
Data on the host is NOT deleted." || return
if pct set "$ctid" -delete "$mp_key" >/dev/null 2>&1; then
msg_ok "Removed ${mp_key} from CT ${ctid}"
else
msg_error "Failed to remove ${mp_key} from CT ${ctid}"
fi
Data on the host is NOT deleted."; then
if pct set "$ctid" -delete "$mp_key" >/dev/null 2>&1; then
results+=("removed ${mp_key}")
else
results+=("FAILED ${mp_key}")
fi
else
results+=("skipped ${mp_key}")
fi
done
header_info
echo -e "${BL}Remove mountpoint — result for CT ${ctid}${CL}\n"
printf ' %s\n' "${results[@]}"
echo
pause
}