mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-03 20:03:25 +01:00
update_lxcs.sh: Add the option to skip stopped LXC (#10783)
* Add the option to skip stopped LXC * Fix issue where a script aborts when /usr/lib/python3.*/EXTERNALLY-MANAGED is not there
This commit is contained in:
committed by
GitHub
parent
12a3b4ecd2
commit
648829f51e
@@ -27,6 +27,7 @@ CL=$(echo "\033[m")
|
||||
header_info
|
||||
echo "Loading..."
|
||||
whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Updater" --yesno "This Will Update LXC Containers. Proceed?" 10 58
|
||||
SKIP_STOPPED=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Skip Not-Running Containers" --yesno "Do you want to skip containers that are not currently running?" 10 58 && echo "yes" || echo "no")
|
||||
NODE=$(hostname)
|
||||
EXCLUDE_MENU=()
|
||||
MSG_MAX_LENGTH=0
|
||||
@@ -67,7 +68,7 @@ function update_container() {
|
||||
alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;;
|
||||
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
||||
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
|
||||
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;
|
||||
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED || true" ;;
|
||||
opensuse) pct exec "$container" -- bash -c "zypper ref && zypper --non-interactive dup" ;;
|
||||
esac
|
||||
}
|
||||
@@ -81,6 +82,12 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||
sleep 1
|
||||
else
|
||||
status=$(pct status $container)
|
||||
if [ "$SKIP_STOPPED" == "yes" ] && [ "$status" == "status: stopped" ]; then
|
||||
header_info
|
||||
echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}${GN} (not running)${CL}"
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user