mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-18 16:32:17 +00: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
|
header_info
|
||||||
echo "Loading..."
|
echo "Loading..."
|
||||||
whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Updater" --yesno "This Will Update LXC Containers. Proceed?" 10 58
|
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)
|
NODE=$(hostname)
|
||||||
EXCLUDE_MENU=()
|
EXCLUDE_MENU=()
|
||||||
MSG_MAX_LENGTH=0
|
MSG_MAX_LENGTH=0
|
||||||
@@ -67,7 +68,7 @@ function update_container() {
|
|||||||
alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;;
|
alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;;
|
||||||
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
||||||
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
|
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" ;;
|
opensuse) pct exec "$container" -- bash -c "zypper ref && zypper --non-interactive dup" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,12 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
|||||||
sleep 1
|
sleep 1
|
||||||
else
|
else
|
||||||
status=$(pct status $container)
|
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")
|
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
|
||||||
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
||||||
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
||||||
|
|||||||
Reference in New Issue
Block a user