feat(update-apps): enhance error handling for unattended mode in resource checks

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
MickLesk
2026-05-07 13:49:58 +02:00
parent 544ac91a2a
commit 2489c70854
3 changed files with 18 additions and 0 deletions

View File

@@ -3230,6 +3230,10 @@ check_container_resources() {
if [[ "$current_ram" -lt "$var_ram" ]] || [[ "$current_cpu" -lt "$var_cpu" ]]; then
msg_warn "Under-provisioned: Required ${var_cpu} CPU/${var_ram}MB RAM, Current ${current_cpu} CPU/${current_ram}MB RAM"
echo -e "${YWB}Please ensure that the ${APP} LXC is configured with at least ${var_cpu} vCPU and ${var_ram} MB RAM for the build process.${CL}\n"
if is_unattended; then
msg_error "Aborted: under-provisioned LXC in unattended mode (${current_cpu} CPU/${current_ram}MB RAM < ${var_cpu} CPU/${var_ram}MB RAM)"
exit 113
fi
echo -ne "${INFO}${HOLD} May cause data loss! ${INFO} Continue update with under-provisioned LXC? <yes/No> "
read -r prompt </dev/tty
if [[ ! ${prompt,,} =~ ^(yes)$ ]]; then
@@ -3253,6 +3257,10 @@ check_container_storage() {
usage=$((100 * used_size / total_size))
if ((usage > 80)); then
msg_warn "Storage is dangerously low (${usage}% used on /boot)"
if is_unattended; then
msg_error "Aborted: storage too low in unattended mode (${usage}% used on /boot)"
exit 114
fi
echo -ne "Continue anyway? <y/N> "
read -r prompt </dev/tty
if [[ ! ${prompt,,} =~ ^(y|yes)$ ]]; then

View File

@@ -868,6 +868,12 @@ get_header() {
# - Returns silently if header not available
# ------------------------------------------------------------------------------
header_info() {
# Guard against printing the header twice in the same session (e.g. when
# the ct script calls header_info at global scope AND again inside
# update_script()).
[[ "${_HEADER_SHOWN:-0}" == "1" ]] && return 0
_HEADER_SHOWN=1
local app_name=$(echo "${APP,,}" | tr -d ' ')
local header_content

View File

@@ -505,6 +505,10 @@ for container in $CHOICE; do
msg_ok "Updated container $container"
elif [ $exit_code -eq 75 ]; then
echo -e "${YW}[WARN]${CL} Container $container skipped (requires interactive mode)"
elif [ $exit_code -eq 113 ]; then
echo -e "${YW}[WARN]${CL} Container $container skipped (under-provisioned: increase CPU/RAM to match template)"
elif [ $exit_code -eq 114 ]; then
echo -e "${YW}[WARN]${CL} Container $container skipped (storage critically low on /boot)"
elif [ "$BACKUP_CHOICE" == "yes" ]; then
msg_error "Update failed for container $container (exit code: $exit_code) — attempting restore"
msg_info "Restoring LXC $container from backup ($STORAGE_CHOICE)"