From 3428070a0963b775575201f28c3ce98849748974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Sat, 28 Jun 2025 12:40:57 -0400 Subject: [PATCH 01/13] Adds script to update LXC services from the host, allowing to automatically increase resources if needed to build the service --- misc/build.func | 4 + tools/pve/update-lxcs-services.sh | 184 ++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 tools/pve/update-lxcs-services.sh diff --git a/misc/build.func b/misc/build.func index b75e5b38..136b3de5 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1096,6 +1096,10 @@ start() { source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) if command -v pveversion >/dev/null 2>&1; then install_script + elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then + VERBOSE="no" + set_std_mode + update_script else CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \ "Support/Update functions for ${APP} LXC. Choose an option:" \ diff --git a/tools/pve/update-lxcs-services.sh b/tools/pve/update-lxcs-services.sh new file mode 100644 index 00000000..e5bcca04 --- /dev/null +++ b/tools/pve/update-lxcs-services.sh @@ -0,0 +1,184 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 tteck +# Author: tteck (tteckster) | Co-Author: remz1337 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +function header_info() { + clear + cat <<"EOF" + __ __ __ __ __ _ ________ _____ _ + / / / /___ ____/ /___ _/ /____ / / | |/ / ____/ / ___/___ ______ __(_)_______ _____ + / / / / __ \/ __ / __ `/ __/ _ \ / / | / / \__ \/ _ \/ ___/ | / / / ___/ _ \/ ___/ +/ /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___ ___/ / __/ / | |/ / / /__/ __(__ ) +\____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/ /____/\___/_/ |___/_/\___/\___/____/ + /_/ + +EOF +} +set -eEuo pipefail +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +CM='\xE2\x9C\x94\033' +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +header_info +echo "Loading..." +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Service Updater" --yesno "This Will Update LXC Services. Proceed?" 10 58 +NODE=$(hostname) +EXCLUDE_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from updates:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') + +function needs_reboot() { + local container=$1 + local os=$(pct config "$container" | awk '/^ostype/ {print $2}') + local reboot_required_file="/var/run/reboot-required.pkgs" + if [ -f "$reboot_required_file" ]; then + if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then + if pct exec "$container" -- [ -s "$reboot_required_file" ]; then + return 0 + fi + fi + fi + return 1 +} + +function update_container_service() { + container=$1 + header_info + name=$(pct exec "$container" hostname) + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + if [[ "$os" == "ubuntu" || "$os" == "debian" || "$os" == "fedora" ]]; then + disk_info=$(pct exec "$container" df /boot | awk 'NR==2{gsub("%","",$5); printf "%s %.1fG %.1fG %.1fG", $5, $3/1024/1024, $2/1024/1024, $4/1024/1024 }') + read -ra disk_info_array <<<"$disk_info" + echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}Boot Disk: ${disk_info_array[0]}% full [${disk_info_array[1]}/${disk_info_array[2]} used, ${disk_info_array[3]} free]${CL}\n" + else + echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}[No disk info for ${os}]${CL}\n" + fi + + #1) Detect service using the service name in the update command + pushd $(mktemp -d) >/dev/null + pct pull "$container" /usr/bin/update update 2>/dev/null + service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') + popd >/dev/null + + #1.1) If update script not detected, return + if [ -z "${service}" ]; then + echo -e "${YW}[WARN]${CL} Update script not found\n" + return + else + echo "${BL}[INFO]${CL} Detected service: ${GN}${service}${CL}\n" + fi + + #2) Extract service build/update resource requirements from config/installation file + script=$(curl -fsSL https://raw.githubusercontent.com/remz1337/ProxmoxVE/remz/ct/${service}.sh) + config=$(pct config "$container") + build_cpu=$(echo "$script" | { grep -m 1 "var_cpu" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_cpu:-||g' | sed 's|}||g') + build_ram=$(echo "$script" | { grep -m 1 "var_ram" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_ram:-||g' | sed 's|}||g') + run_cpu=$(echo "$script" | { grep -m 1 "pct set \$CTID -cores" || test $? = 1; } | sed 's|.*cores ||g') + run_ram=$(echo "$script" | { grep -m 1 "pct set \$CTID -memory" || test $? = 1; } | sed 's|.*memory ||g') + current_cpu=$(echo "$config" | grep -m 1 "cores:" | sed 's|cores: ||g') + current_ram=$(echo "$config" | grep -m 1 "memory:" | sed 's|memory: ||g') + + #Test if all values are valid (>0) + if [ -z "${run_cpu}" ] || [ "$run_cpu" -le 0 ]; then + #echo "No valid value found for run_cpu. Assuming same as current configuration." + run_cpu=$current_cpu + fi + + if [ -z "${run_ram}" ] || [ "$run_ram" -le 0 ]; then + #echo "No valid value found for run_ram. Assuming same as current configuration." + run_ram=$current_ram + fi + + if [ -z "${build_cpu}" ] || [ "$build_cpu" -le 0 ]; then + #echo "No valid value found for build_cpu. Assuming same as current configuration." + build_cpu=$current_cpu + fi + + if [ -z "${build_ram}" ] || [ "$build_ram" -le 0 ]; then + #echo "No valid value found for build_ram. Assuming same as current configuration." + build_ram=$current_ram + fi + + UPDATE_BUILD_RESOURCES=0 + if [ "$build_cpu" -gt "$run_cpu" ] || [ "$build_ram" -gt "$run_ram" ]; then + UPDATE_BUILD_RESOURCES=1 + fi + + #3) if build resources are different than run resources, then: + if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then + #pct shutdown "$container" + #sleep 2 + pct set "$container" --cores "$build_cpu" --memory "$build_ram" + pct restart "$container" + sleep 2 + fi + + #4) Update service, using the update command + UPDATE_CMD="export PHS_SILENT=1;update;" + case "$os" in + alpine) pct exec "$container" -- ash -c "$UPDATE_CMD" ;; + archlinux) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + fedora | rocky | centos | alma) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + ubuntu | debian | devuan) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + opensuse) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + esac + + #5) if build resources are different than run resources, then: + if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then + #pct shutdown "$container" + #sleep 2 + pct set "$container" --cores "$run_cpu" --memory "$run_ram" + #pct restart "$container" + #sleep 2 + fi +} + +containers_needing_reboot=() +header_info +for container in $(pct list | awk '{if(NR>1) print $1}'); do + if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}" + sleep 1 + else + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" + pct start $container + echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" + sleep 5 + #update_container $container + update_container_service $container + echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" + pct shutdown $container & + elif [ "$status" == "status: running" ]; then + #update_container $container + update_container_service $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 + fi +done +wait +header_info +echo -e "${GN}The process is complete, and the containers have been successfully updated.${CL}\n" +if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then + echo -e "${RD}The following containers require a reboot:${CL}" + for container_name in "${containers_needing_reboot[@]}"; do + echo "$container_name" + done +fi +echo "" From 5ab98dedd942ab7239f5c6cc92c0cc5127e4fe86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Wed, 2 Jul 2025 17:10:49 -0400 Subject: [PATCH 02/13] (WIP) Support updating multiple containers --- tools/pve/update-apps.sh | 88 ++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index e7712e4e..98e5e8ab 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash # Copyright (c) 2021-2025 community-scripts ORG -# Author: BvdBerg01 +# Author: BvdBerg01 | Co-Author: remz1337 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) + function header_info { clear cat <<"EOF" @@ -16,8 +18,6 @@ function header_info { EOF } -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) - header_info echo "Loading..." whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "This will update LXC container. Proceed?" 10 58 || exit @@ -45,8 +45,8 @@ while read -r container; do done <<< "$containers" CHOICE=$(whiptail --title "LXC Container Update" \ - --radiolist "Select LXC container to update:" 25 60 13 \ - "${menu_items[@]}" 3>&2 2>&1 1>&3) + --checklist "Select LXC containers to update:" 25 60 13 \ + "${menu_items[@]}" 3>&2 2>&1 1>&3 | tr -d '"') if [ -z "$CHOICE" ]; then whiptail --title "LXC Container Update" \ @@ -55,12 +55,21 @@ if [ -z "$CHOICE" ]; then fi header_info -if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Do you want to create a backup from your container?" 10 58); then +BACKUP_CHOICE="no" +if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Do you want to backup your containers before update?" 10 58); then + BACKUP_CHOICE="yes" +fi +UNATTENDED_UPDATE="no" +if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "Run updates unattended?" 10 58); then + UNATTENDED_UPDATE="yes" +fi + +if [ "$BACKUP_CHOICE" == "yes" ]; then STORAGES=$(awk '/^(\S+):/ {storage=$2} /content.*backup/ {print storage}' /etc/pve/storage.cfg) if [ -z "$STORAGES" ]; then - whiptail --msgbox "Geen opslag met 'backup' gevonden!" 8 40 + whiptail --msgbox "No storage with 'backup' found!" 8 40 exit 1 fi @@ -75,37 +84,56 @@ if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Updat msg_error "No storage selected!" exit 1 fi +fi - msg_info "Creating backup" - vzdump $CHOICE --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" > /dev/null 2>&1 +function backup_container(){ + msg_info "Creating backup for container $1" + vzdump $1 --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" > /dev/null 2>&1 status=$? if [ $status -eq 0 ]; then - msg_ok "Backup created" - pct exec $CHOICE -- update --from-pve - exit_code=$? + msg_ok "Backup created" else - msg_error "Backup failed" + msg_error "Backup failed for container $1" + exit 1 fi +} -else - pct exec $CHOICE -- update --from-pve - exit_code=$? +UPDATE_CMD="update;" +if [ "$UNATTENDED_UPDATE" == "yes" ];then + UPDATE_CMD="export PHS_SILENT=1;update;" fi -if [ $exit_code -eq 0 ]; then - msg_ok "Update completed" -else - msg_info "Restoring LXC from backup" - pct stop $CHOICE - LXC_STORAGE=$(pct config $CHOICE | awk -F '[:,]' '/rootfs/ {print $2}') - pct restore $CHOICE /var/lib/vz/dump/vzdump-lxc-$CHOICE-*.tar.zst --storage $LXC_STORAGE --force > /dev/null 2>&1 - pct start $CHOICE - restorestatus=$? - if [ $restorestatus -eq 0 ]; then - msg_ok "Restored LXC from backup" - else - msg_error "Restored LXC from backup failed" +for container in $CHOICE; do + echo "Updating container:$container" + + if [ "BACKUP_CHOICE" == "yes" ];then + backup_container $container fi -fi + #CHECK FOR RESOURCES + + #pct exec $container -- update + pct exec "$container" -- "$UPDATE_CMD" + exit_code=$? + + if [ $exit_code -eq 0 ]; then + msg_ok "Update completed" + elif [ "BACKUP_CHOICE" == "yes" ];then + msg_info "Restoring LXC from backup" + pct stop $container + LXC_STORAGE=$(pct config $container | awk -F '[:,]' '/rootfs/ {print $2}') + pct restore $container /var/lib/vz/dump/vzdump-lxc-${container}-*.tar.zst --storage $LXC_STORAGE --force > /dev/null 2>&1 + pct start $container + restorestatus=$? + if [ $restorestatus -eq 0 ]; then + msg_ok "Restored LXC from backup" + else + msg_error "Restored LXC from backup failed" + exit 1 + fi + else + msg_error "Update failed for container $container. Exiting" + exit 1 + fi +done From f586a21e1e263bcd0e30f7a1aeb0f4678de39f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Wed, 2 Jul 2025 21:17:49 -0400 Subject: [PATCH 03/13] Add logic for unattended updates and reboot containers if needed (following user prompt) --- tools/pve/update-apps.sh | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 98e5e8ab..43a17bfc 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -104,6 +104,7 @@ if [ "$UNATTENDED_UPDATE" == "yes" ];then UPDATE_CMD="export PHS_SILENT=1;update;" fi +containers_needing_reboot=() for container in $CHOICE; do echo "Updating container:$container" @@ -113,10 +114,24 @@ for container in $CHOICE; do #CHECK FOR RESOURCES - #pct exec $container -- update - pct exec "$container" -- "$UPDATE_CMD" + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + + #4) Update service, using the update command + case "$os" in + alpine) pct exec "$container" -- ash -c "$UPDATE_CMD" ;; + archlinux) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + fedora | rocky | centos | alma) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + ubuntu | debian | devuan) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + opensuse) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; + esac exit_code=$? + 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 + if [ $exit_code -eq 0 ]; then msg_ok "Update completed" elif [ "BACKUP_CHOICE" == "yes" ];then @@ -137,3 +152,22 @@ for container in $CHOICE; do exit 1 fi done + +wait +header_info +echo -e "${GN}The process is complete, and the containers have been successfully updated.${CL}\n" +if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then + echo -e "${RD}The following containers require a reboot:${CL}" + for container_name in "${containers_needing_reboot[@]}"; do + echo "$container_name" + done + echo -ne "${INFO} Do you wish to reboot these containers? " + read -r prompt + if [[ ${prompt,,} =~ ^(yes)$ ]]; then + echo -e "${CROSS}${HOLD} ${YWB}Rebooting containers.${CL}" + for container_name in "${containers_needing_reboot[@]}"; do + container=$(echo $container_name | cut -d " " -f 1) + pct reboot ${container} + done + fi +fi From b62b0ccc9b19900a8fb59bd221a237903b3ff290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Wed, 2 Jul 2025 21:25:41 -0400 Subject: [PATCH 04/13] Adds resources scaling logic --- tools/pve/update-apps.sh | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 43a17bfc..b086d299 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -112,7 +112,60 @@ for container in $CHOICE; do backup_container $container fi - #CHECK FOR RESOURCES + #1) Detect service using the service name in the update command + pushd $(mktemp -d) >/dev/null + pct pull "$container" /usr/bin/update update 2>/dev/null + service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') + popd >/dev/null + + #1.1) If update script not detected, return + if [ -z "${service}" ]; then + echo -e "${YW}[WARN]${CL} Update script not found. Skipping to next container\n" + continue + else + echo "${BL}[INFO]${CL} Detected service: ${GN}${service}${CL}\n" + fi + + #2) Extract service build/update resource requirements from config/installation file + script=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/${service}.sh) + config=$(pct config "$container") + build_cpu=$(echo "$script" | { grep -m 1 "var_cpu" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_cpu:-||g' | sed 's|}||g') + build_ram=$(echo "$script" | { grep -m 1 "var_ram" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_ram:-||g' | sed 's|}||g') + run_cpu=$(echo "$script" | { grep -m 1 "pct set \$CTID -cores" || test $? = 1; } | sed 's|.*cores ||g') + run_ram=$(echo "$script" | { grep -m 1 "pct set \$CTID -memory" || test $? = 1; } | sed 's|.*memory ||g') + current_cpu=$(echo "$config" | grep -m 1 "cores:" | sed 's|cores: ||g') + current_ram=$(echo "$config" | grep -m 1 "memory:" | sed 's|memory: ||g') + + #Test if all values are valid (>0) + if [ -z "${run_cpu}" ] || [ "$run_cpu" -le 0 ]; then + #echo "No valid value found for run_cpu. Assuming same as current configuration." + run_cpu=$current_cpu + fi + + if [ -z "${run_ram}" ] || [ "$run_ram" -le 0 ]; then + #echo "No valid value found for run_ram. Assuming same as current configuration." + run_ram=$current_ram + fi + + if [ -z "${build_cpu}" ] || [ "$build_cpu" -le 0 ]; then + #echo "No valid value found for build_cpu. Assuming same as current configuration." + build_cpu=$current_cpu + fi + + if [ -z "${build_ram}" ] || [ "$build_ram" -le 0 ]; then + #echo "No valid value found for build_ram. Assuming same as current configuration." + build_ram=$current_ram + fi + + UPDATE_BUILD_RESOURCES=0 + if [ "$build_cpu" -gt "$run_cpu" ] || [ "$build_ram" -gt "$run_ram" ]; then + UPDATE_BUILD_RESOURCES=1 + fi + + #3) if build resources are different than run resources, then: + if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then + pct set "$container" --cores "$build_cpu" --memory "$build_ram" + fi os=$(pct config "$container" | awk '/^ostype/ {print $2}') @@ -126,6 +179,11 @@ for container in $CHOICE; do esac exit_code=$? + #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" + 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) From 6c507a0f9064983e574d8ad6a4f859ac69bee0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Wed, 2 Jul 2025 21:34:49 -0400 Subject: [PATCH 05/13] Remove old script and cleanup some messages --- tools/pve/update-apps.sh | 8 +- tools/pve/update-lxcs-services.sh | 184 ------------------------------ 2 files changed, 4 insertions(+), 188 deletions(-) delete mode 100644 tools/pve/update-lxcs-services.sh diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index b086d299..0c1a979f 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -106,7 +106,7 @@ fi containers_needing_reboot=() for container in $CHOICE; do - echo "Updating container:$container" + msg_info "Updating container $container" if [ "BACKUP_CHOICE" == "yes" ];then backup_container $container @@ -120,10 +120,10 @@ for container in $CHOICE; do #1.1) If update script not detected, return if [ -z "${service}" ]; then - echo -e "${YW}[WARN]${CL} Update script not found. Skipping to next container\n" + echo -e "${YW}[WARN]${CL} Update script not found. Skipping to next container" continue else - echo "${BL}[INFO]${CL} Detected service: ${GN}${service}${CL}\n" + echo -e "${BL}[INFO]${CL} Detected service: ${GN}${service}${CL}" fi #2) Extract service build/update resource requirements from config/installation file @@ -191,7 +191,7 @@ for container in $CHOICE; do fi if [ $exit_code -eq 0 ]; then - msg_ok "Update completed" + msg_ok "Updated container $container" elif [ "BACKUP_CHOICE" == "yes" ];then msg_info "Restoring LXC from backup" pct stop $container diff --git a/tools/pve/update-lxcs-services.sh b/tools/pve/update-lxcs-services.sh deleted file mode 100644 index e5bcca04..00000000 --- a/tools/pve/update-lxcs-services.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) | Co-Author: remz1337 -# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE - -function header_info() { - clear - cat <<"EOF" - __ __ __ __ __ _ ________ _____ _ - / / / /___ ____/ /___ _/ /____ / / | |/ / ____/ / ___/___ ______ __(_)_______ _____ - / / / / __ \/ __ / __ `/ __/ _ \ / / | / / \__ \/ _ \/ ___/ | / / / ___/ _ \/ ___/ -/ /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___ ___/ / __/ / | |/ / / /__/ __(__ ) -\____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/ /____/\___/_/ |___/_/\___/\___/____/ - /_/ - -EOF -} -set -eEuo pipefail -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -CM='\xE2\x9C\x94\033' -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -header_info -echo "Loading..." -whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Service Updater" --yesno "This Will Update LXC Services. Proceed?" 10 58 -NODE=$(hostname) -EXCLUDE_MENU=() -MSG_MAX_LENGTH=0 -while read -r TAG ITEM; do - OFFSET=2 - ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET - EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF") -done < <(pct list | awk 'NR>1') -excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from updates:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') - -function needs_reboot() { - local container=$1 - local os=$(pct config "$container" | awk '/^ostype/ {print $2}') - local reboot_required_file="/var/run/reboot-required.pkgs" - if [ -f "$reboot_required_file" ]; then - if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then - if pct exec "$container" -- [ -s "$reboot_required_file" ]; then - return 0 - fi - fi - fi - return 1 -} - -function update_container_service() { - container=$1 - header_info - name=$(pct exec "$container" hostname) - os=$(pct config "$container" | awk '/^ostype/ {print $2}') - if [[ "$os" == "ubuntu" || "$os" == "debian" || "$os" == "fedora" ]]; then - disk_info=$(pct exec "$container" df /boot | awk 'NR==2{gsub("%","",$5); printf "%s %.1fG %.1fG %.1fG", $5, $3/1024/1024, $2/1024/1024, $4/1024/1024 }') - read -ra disk_info_array <<<"$disk_info" - echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}Boot Disk: ${disk_info_array[0]}% full [${disk_info_array[1]}/${disk_info_array[2]} used, ${disk_info_array[3]} free]${CL}\n" - else - echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}[No disk info for ${os}]${CL}\n" - fi - - #1) Detect service using the service name in the update command - pushd $(mktemp -d) >/dev/null - pct pull "$container" /usr/bin/update update 2>/dev/null - service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') - popd >/dev/null - - #1.1) If update script not detected, return - if [ -z "${service}" ]; then - echo -e "${YW}[WARN]${CL} Update script not found\n" - return - else - echo "${BL}[INFO]${CL} Detected service: ${GN}${service}${CL}\n" - fi - - #2) Extract service build/update resource requirements from config/installation file - script=$(curl -fsSL https://raw.githubusercontent.com/remz1337/ProxmoxVE/remz/ct/${service}.sh) - config=$(pct config "$container") - build_cpu=$(echo "$script" | { grep -m 1 "var_cpu" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_cpu:-||g' | sed 's|}||g') - build_ram=$(echo "$script" | { grep -m 1 "var_ram" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_ram:-||g' | sed 's|}||g') - run_cpu=$(echo "$script" | { grep -m 1 "pct set \$CTID -cores" || test $? = 1; } | sed 's|.*cores ||g') - run_ram=$(echo "$script" | { grep -m 1 "pct set \$CTID -memory" || test $? = 1; } | sed 's|.*memory ||g') - current_cpu=$(echo "$config" | grep -m 1 "cores:" | sed 's|cores: ||g') - current_ram=$(echo "$config" | grep -m 1 "memory:" | sed 's|memory: ||g') - - #Test if all values are valid (>0) - if [ -z "${run_cpu}" ] || [ "$run_cpu" -le 0 ]; then - #echo "No valid value found for run_cpu. Assuming same as current configuration." - run_cpu=$current_cpu - fi - - if [ -z "${run_ram}" ] || [ "$run_ram" -le 0 ]; then - #echo "No valid value found for run_ram. Assuming same as current configuration." - run_ram=$current_ram - fi - - if [ -z "${build_cpu}" ] || [ "$build_cpu" -le 0 ]; then - #echo "No valid value found for build_cpu. Assuming same as current configuration." - build_cpu=$current_cpu - fi - - if [ -z "${build_ram}" ] || [ "$build_ram" -le 0 ]; then - #echo "No valid value found for build_ram. Assuming same as current configuration." - build_ram=$current_ram - fi - - UPDATE_BUILD_RESOURCES=0 - if [ "$build_cpu" -gt "$run_cpu" ] || [ "$build_ram" -gt "$run_ram" ]; then - UPDATE_BUILD_RESOURCES=1 - fi - - #3) if build resources are different than run resources, then: - if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then - #pct shutdown "$container" - #sleep 2 - pct set "$container" --cores "$build_cpu" --memory "$build_ram" - pct restart "$container" - sleep 2 - fi - - #4) Update service, using the update command - UPDATE_CMD="export PHS_SILENT=1;update;" - case "$os" in - alpine) pct exec "$container" -- ash -c "$UPDATE_CMD" ;; - archlinux) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; - fedora | rocky | centos | alma) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; - ubuntu | debian | devuan) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; - opensuse) pct exec "$container" -- bash -c "$UPDATE_CMD" ;; - esac - - #5) if build resources are different than run resources, then: - if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then - #pct shutdown "$container" - #sleep 2 - pct set "$container" --cores "$run_cpu" --memory "$run_ram" - #pct restart "$container" - #sleep 2 - fi -} - -containers_needing_reboot=() -header_info -for container in $(pct list | awk '{if(NR>1) print $1}'); do - if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then - header_info - echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}" - sleep 1 - else - status=$(pct status $container) - template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") - if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then - echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" - pct start $container - echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" - sleep 5 - #update_container $container - update_container_service $container - echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" - pct shutdown $container & - elif [ "$status" == "status: running" ]; then - #update_container $container - update_container_service $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 - fi -done -wait -header_info -echo -e "${GN}The process is complete, and the containers have been successfully updated.${CL}\n" -if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then - echo -e "${RD}The following containers require a reboot:${CL}" - for container_name in "${containers_needing_reboot[@]}"; do - echo "$container_name" - done -fi -echo "" From ae2c84500ac0459a1b32ecedc00b6ba52611a82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 14:35:06 -0400 Subject: [PATCH 06/13] Allow updating stopped containers and check the download of the install script needed to assess build resource requirements --- tools/pve/update-apps.sh | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 0c1a979f..f7727977 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -38,8 +38,10 @@ while read -r container; do container_name=$(echo $container | awk '{print $2}') container_status=$(echo $container | awk '{print $3}') formatted_line=$(printf "$FORMAT" "$container_name" "$container_status") - IS_HELPERSCRIPT_LXC=$(pct exec $container_id -- [ -e /usr/bin/update ] && echo true || echo false) - if [ "$IS_HELPERSCRIPT_LXC" = true ]; then + #IS_HELPERSCRIPT_LXC=$(pct exec $container_id -- [ -e /usr/bin/update ] && echo true || echo false) + #if [ "$IS_HELPERSCRIPT_LXC" = true ]; then + detect_service $container + if [ -n "${service}" ]; then menu_items+=("$container_id" "$formatted_line" "OFF") fi done <<< "$containers" @@ -99,6 +101,13 @@ function backup_container(){ fi } +function detect_service(){ + pushd $(mktemp -d) >/dev/null + pct pull "$1" /usr/bin/update update 2>/dev/null + service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') + popd >/dev/null +} + UPDATE_CMD="update;" if [ "$UNATTENDED_UPDATE" == "yes" ];then UPDATE_CMD="export PHS_SILENT=1;update;" @@ -113,10 +122,7 @@ for container in $CHOICE; do fi #1) Detect service using the service name in the update command - pushd $(mktemp -d) >/dev/null - pct pull "$container" /usr/bin/update update 2>/dev/null - service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') - popd >/dev/null + detect_service $container #1.1) If update script not detected, return if [ -z "${service}" ]; then @@ -127,7 +133,14 @@ for container in $CHOICE; do fi #2) Extract service build/update resource requirements from config/installation file - script=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/${service}.sh) + script=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/${service}.sh) + + #2.1) Check if the script downloaded successfully + if [ $? -ne 0 ]; then + echo -e "${RD}[ERROR]${CL} Issue while downloading install script." + echo -e "${YW}[WARN]${CL} Unable to assess build resource requirements. Proceeding with current resources." + fi + config=$(pct config "$container") build_cpu=$(echo "$script" | { grep -m 1 "var_cpu" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_cpu:-||g' | sed 's|}||g') build_ram=$(echo "$script" | { grep -m 1 "var_ram" || test $? = 1; } | sed 's|.*=||g' | sed 's|"||g' | sed 's|.*var_ram:-||g' | sed 's|}||g') @@ -168,6 +181,14 @@ for container in $CHOICE; do fi os=$(pct config "$container" | awk '/^ostype/ {print $2}') + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" + pct start $container + echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" + sleep 5 + fi #4) Update service, using the update command case "$os" in @@ -179,6 +200,11 @@ 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" From 0f772b7df561b8887b7cb35b5841eedefa1f0a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 14:42:55 -0400 Subject: [PATCH 07/13] Move functions to the top --- tools/pve/update-apps.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index f7727977..1c392430 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -18,6 +18,26 @@ function header_info { EOF } +function detect_service(){ + pushd $(mktemp -d) >/dev/null + pct pull "$1" /usr/bin/update update 2>/dev/null + service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') + popd >/dev/null +} + +function backup_container(){ + msg_info "Creating backup for container $1" + vzdump $1 --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" > /dev/null 2>&1 + status=$? + + if [ $status -eq 0 ]; then + msg_ok "Backup created" + else + msg_error "Backup failed for container $1" + exit 1 + fi +} + header_info echo "Loading..." whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "This will update LXC container. Proceed?" 10 58 || exit @@ -88,26 +108,6 @@ if [ "$BACKUP_CHOICE" == "yes" ]; then fi fi -function backup_container(){ - msg_info "Creating backup for container $1" - vzdump $1 --compress zstd --storage $STORAGE_CHOICE -notes-template "community-scripts backup updater" > /dev/null 2>&1 - status=$? - - if [ $status -eq 0 ]; then - msg_ok "Backup created" - else - msg_error "Backup failed for container $1" - exit 1 - fi -} - -function detect_service(){ - pushd $(mktemp -d) >/dev/null - pct pull "$1" /usr/bin/update update 2>/dev/null - service=$(cat update | sed 's|.*/ct/||g' | sed 's|\.sh).*||g') - popd >/dev/null -} - UPDATE_CMD="update;" if [ "$UNATTENDED_UPDATE" == "yes" ];then UPDATE_CMD="export PHS_SILENT=1;update;" From 9b1382ddcf513030ae4205e14ecadf082e69c163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 15:02:40 -0400 Subject: [PATCH 08/13] Remove msg_info call to prevent spinner from overriding the whiptail menu --- tools/pve/update-apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 1c392430..e91677d3 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -115,7 +115,7 @@ fi containers_needing_reboot=() for container in $CHOICE; do - msg_info "Updating container $container" + echo -e "${BL}[INFO]${CL} Updating container $container" if [ "BACKUP_CHOICE" == "yes" ];then backup_container $container @@ -138,7 +138,7 @@ for container in $CHOICE; do #2.1) Check if the script downloaded successfully if [ $? -ne 0 ]; then echo -e "${RD}[ERROR]${CL} Issue while downloading install script." - echo -e "${YW}[WARN]${CL} Unable to assess build resource requirements. Proceeding with current resources." + echo -e "${YW}[WARN]${CL} Unable to assess build resource requirements. Proceeding with current resources." fi config=$(pct config "$container") From 3e2924d2ed56f43f640c63fe9a3f9aab0ce860aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 15:30:07 -0400 Subject: [PATCH 09/13] Fix backup storage detection to support local dir --- tools/pve/update-apps.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 1c392430..adcbe20c 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -38,6 +38,31 @@ function backup_container(){ fi } +function get_backup_storages(){ +STORAGES=$(awk ' +/^[a-z]+:/ { + if (name != "") { + if (has_backup || (!has_content && type == "dir")) print name + } + split($0, a, ":") + type = a[1] + name = a[2] + sub(/^ +/, "", name) + has_content = 0 + has_backup = 0 +} +/^ +content/ { + has_content = 1 + if ($0 ~ /backup/) has_backup = 1 +} +END { + if (name != "") { + if (has_backup || (!has_content && type == "dir")) print name + } +} +' /etc/pve/storage.cfg) +} + header_info echo "Loading..." whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Update" --yesno "This will update LXC container. Proceed?" 10 58 || exit @@ -88,7 +113,8 @@ if(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LXC Container Updat fi if [ "$BACKUP_CHOICE" == "yes" ]; then - STORAGES=$(awk '/^(\S+):/ {storage=$2} /content.*backup/ {print storage}' /etc/pve/storage.cfg) + #STORAGES=$(awk '/^(\S+):/ {storage=$2} /content.*backup/ {print storage}' /etc/pve/storage.cfg) + get_backup_storages if [ -z "$STORAGES" ]; then whiptail --msgbox "No storage with 'backup' found!" 8 40 From aab59bce4bebeb3c3f806be3f3140db6df193a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 15:41:19 -0400 Subject: [PATCH 10/13] Fix missing $ to check variable value and allow backup of container --- tools/pve/update-apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index ef8fb9a7..6268cf23 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -143,7 +143,7 @@ containers_needing_reboot=() for container in $CHOICE; do echo -e "${BL}[INFO]${CL} Updating container $container" - if [ "BACKUP_CHOICE" == "yes" ];then + if [ "$BACKUP_CHOICE" == "yes" ];then backup_container $container fi From 503e9be156fbe31679a0f63a93f30dfb751d3a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 16:24:31 -0400 Subject: [PATCH 11/13] Detect helper scripts based on tags (so it can detect even if the container is shutdown) --- tools/pve/update-apps.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 6268cf23..73ee0474 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -77,18 +77,16 @@ fi menu_items=() FORMAT="%-10s %-15s %-10s" +TAGS="community-script|proxmox-helper-scripts" while read -r container; do - container_id=$(echo $container | awk '{print $1}') - container_name=$(echo $container | awk '{print $2}') - container_status=$(echo $container | awk '{print $3}') - formatted_line=$(printf "$FORMAT" "$container_name" "$container_status") - #IS_HELPERSCRIPT_LXC=$(pct exec $container_id -- [ -e /usr/bin/update ] && echo true || echo false) - #if [ "$IS_HELPERSCRIPT_LXC" = true ]; then - detect_service $container - if [ -n "${service}" ]; then - menu_items+=("$container_id" "$formatted_line" "OFF") - fi + container_id=$(echo $container | awk '{print $1}') + container_name=$(echo $container | awk '{print $2}') + container_status=$(echo $container | awk '{print $3}') + formatted_line=$(printf "$FORMAT" "$container_name" "$container_status") + if pct config $container | grep -E "^tags:.*(${TAGS}).*"; then + menu_items+=("$container_id" "$formatted_line" "OFF") + fi done <<< "$containers" CHOICE=$(whiptail --title "LXC Container Update" \ From 3652194d24bf82e88ef7f253e0bf64bcc9fb401e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 16:37:54 -0400 Subject: [PATCH 12/13] Fix tag check --- tools/pve/update-apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index 73ee0474..c2ff6c8c 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -84,7 +84,7 @@ while read -r container; do container_name=$(echo $container | awk '{print $2}') container_status=$(echo $container | awk '{print $3}') formatted_line=$(printf "$FORMAT" "$container_name" "$container_status") - if pct config $container | grep -E "^tags:.*(${TAGS}).*"; then + if pct config "$container_id" | grep -qE "^tags:.*(${TAGS}).*"; then menu_items+=("$container_id" "$formatted_line" "OFF") fi done <<< "$containers" From 787bd613609b257c0c1d4d3430c5defc077ce085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Mon, 21 Jul 2025 16:42:16 -0400 Subject: [PATCH 13/13] The detect_service function needs to have the container running --- tools/pve/update-apps.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/pve/update-apps.sh b/tools/pve/update-apps.sh index c2ff6c8c..adb7987e 100644 --- a/tools/pve/update-apps.sh +++ b/tools/pve/update-apps.sh @@ -145,6 +145,16 @@ for container in $CHOICE; do backup_container $container fi + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" + pct start $container + echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" + sleep 5 + fi + #1) Detect service using the service name in the update command detect_service $container @@ -204,16 +214,6 @@ for container in $CHOICE; do pct set "$container" --cores "$build_cpu" --memory "$build_ram" fi - os=$(pct config "$container" | awk '/^ostype/ {print $2}') - status=$(pct status $container) - template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") - if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then - echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" - pct start $container - echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" - sleep 5 - fi - #4) Update service, using the update command case "$os" in alpine) pct exec "$container" -- ash -c "$UPDATE_CMD" ;;