Files
ProxmoxHelper/ReleaseUpgradeALL.sh
Bram Prieshof 376b1dfa7c Fixed Debian13 containers being unable to start after upgrade
* This was caused by outdated SystemD generator, this file will be updated when upgrading the container
2026-01-11 17:46:41 +01:00

131 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
#########################################
# ProxMox update tools #
# Upgrade OS release on all CT`s/VM`s #
# @author: Bram Prieshof #
#########################################
#Dirs
WorkDir=$(dirname $0)
LogDir=$WorkDir/RelUpgradelogs
#Load functions
source $WorkDir/functions.sh
#Create Log folder
if [ ! -d $LogDir ]; then
mkdir $LogDir
fi
#ID list of excluded VM/CT's
ExcludeList=()
#Get what sould be updated
UpdateVM=true
UpdateCT=true
while true; do
read -p "Wich software should be updated (D)Debian, (A)Alpine or (B)oth? " sofq
case $sofq in
[Dd]* )
DoDebianReleaseUpdate=true
DoAlpineReleaseUpdate=false
DoFedoraReleaseUpdate=false
break;;
[Aa]* )
DoDebianReleaseUpdate=false
DoAlpineReleaseUpdate=true
DoFedoraReleaseUpdate=false
break;;
[Bb]* )
DoDebianReleaseUpdate=true
DoAlpineReleaseUpdate=true
DoFedoraReleaseUpdate=false
break;;
* ) echo "Please answer with (D)Debian, (A)Alpine or (B)oth.";;
esac
done
#Get required versions to upgrade to
if $DoDebianReleaseUpdate; then
echo "Enter the Debian version to upgrade to"
read NewDebianVersion
while true; do
read -p "Upgrade to Debian $NewDebianVersion, is this correct? -> yes/no?" yn
case $yn in
[Nn]* )
echo "Enter the Debian version to upgrade to"
read NewDebianVersion
;;
[Yy]* ) break;;
* ) echo "Choose yes or no.";;
esac
done
if [ "${NewDebianVersion}" = "trixie" ]; then
curl -o /tmp/lxc.generator "https://raw.githubusercontent.com/lxc/distrobuilder/refs/heads/main/distrobuilder/lxc.generator"
# Check if the download was successful
if [ $? -ne 0 ]; then
echo "Downloading of lxc.generator from github failed. Exiting."
exit 1
fi
fi
fi
if $DoAlpineReleaseUpdate; then
echo "Enter the Alpine version to upgrade to"
read NewAlpineVersion
while true; do
read -p "Upgrade to Alpine $NewAlpineVersion, is this correct? -> yes/no?" yn
case $yn in
[Nn]* )
echo "Enter the Alpine version to upgrade to"
read NewAlpineVersion
;;
[Yy]* ) break;;
* ) echo "Choose yes or no.";;
esac
done
fi
if $DoFedoraReleaseUpdate; then
echo "Enter the Fedora version to upgrade to"
read NewFedoraVersion
while true; do
read -p "Upgrade to Fedora $NewFedoraVersion, is this correct? -> yes/no?" yn
case $yn in
[Nn]* )
echo "Enter the Fedora version to upgrade to"
read NewFedoraVersion
;;
[Yy]* ) break;;
* ) echo "Choose yes or no.";;
esac
done
fi
#CT updates
if $UpdateCT; then
TYPE=CT;
CTS=($(pct list | tail -n+2 | awk '{print $1}'))
for CTID in "${CTS[@]}"; do
#Skip CT if in ExcludeList
if [[ "${ExcludeList[*]}" =~ $CTID ]]; then echo "Notice: $CTID excluded"; continue; fi
# Skip CT if not running
if ! $(CT-State $CTID); then echo "Notice: $CTID not running"; continue; fi
#DEBUG echo "Task for $CTID"
CT-UpgradeRelease $CTID | tee "$LogDir"/"$CTID"_Release.log
done
fi
#VM Updates
if $UpdateVM; then
TYPE=VM;
VMS=($(qm list | tail -n+2 | awk '{print $1}'))
for VMID in "${VMS[@]}"; do
#Skip VM if in ExcludeList
if [[ "${ExcludeList[*]}" =~ $VMID ]]; then echo "Notice: $VMID excluded"; continue; fi
# Skip VM if not running
if ! $(VM-State $VMID); then echo "Notice: $VMID not running"; continue; fi
#DEBUG echo "Task for $VMID"
VM-UpgradeRelease $VMID | tee "$LogDir"/"$VMID"_Release.log
done
fi