From 585de1ba0cb4e64177787e99ec0af9c179202e2e Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Apr 2026 13:30:20 +0200 Subject: [PATCH] fix(update-lxcs/apps): avoid pct exec on containers mid-shutdown (#14050) Both update-lxcs.sh and update-apps.sh backgrounded pct shutdown and then immediately called pct exec on the same container, causing 'Error: unexpected status' which terminated the loop after the first container. update-lxcs.sh: wrapped reboot-required and patchmon-agent checks in a guard that only runs them when the container was already running (not one that was started and is now being shut down). update-apps.sh: moved pct set (resource reset) and the pct exec reboot-required check to run before pct shutdown is issued. Fixes #14027 --- tools/pve/update-apps.sh | 10 +++++----- tools/pve/update-lxcs.sh | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 4bb668be3..129420f9e 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -405,11 +405,6 @@ for container in $CHOICE; do esac exit_code=$? - if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then - echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" - pct shutdown $container & - fi - #5) if build resources are different than run resources, then: if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then pct set "$container" --cores "$run_cpu" --memory "$run_ram" @@ -421,6 +416,11 @@ for container in $CHOICE; do containers_needing_reboot+=("$container ($container_hostname)") fi + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" + pct shutdown $container &>/dev/null & + fi + if [ $exit_code -eq 0 ]; then msg_ok "Updated container $container" elif [ $exit_code -eq 75 ]; then diff --git a/tools/pve/update-lxcs.sh b/tools/pve/update-lxcs.sh index 66edcd0e9..52e9d2528 100644 --- a/tools/pve/update-lxcs.sh +++ b/tools/pve/update-lxcs.sh @@ -110,15 +110,17 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do elif [ "$status" == "status: running" ]; then update_container $container fi - if pct exec "$container" -- [ -e "/var/run/reboot-required" ]; then - # Get the container's hostname and add it to the list - container_hostname=$(pct exec "$container" hostname) - containers_needing_reboot+=("$container ($container_hostname)") - fi - # check if patchmon agent is present in container and run a report if found - if pct exec "$container" -- [ -e "/usr/local/bin/patchmon-agent" ]; then - echo -e "${BL}[Info]${GN} patchmon-agent found in ${BL} $container ${CL}, triggering report. \n" - pct exec "$container" -- "/usr/local/bin/patchmon-agent" "report" + if [ "$status" == "status: running" ]; then + if pct exec "$container" -- [ -e "/var/run/reboot-required" ]; then + # Get the container's hostname and add it to the list + container_hostname=$(pct exec "$container" hostname) + containers_needing_reboot+=("$container ($container_hostname)") + fi + # check if patchmon agent is present in container and run a report if found + if pct exec "$container" -- [ -e "/usr/local/bin/patchmon-agent" ]; then + echo -e "${BL}[Info]${GN} patchmon-agent found in ${BL} $container ${CL}, triggering report. \n" + pct exec "$container" -- "/usr/local/bin/patchmon-agent" "report" + fi fi fi done