Added release-upgrade scripts
This commit is contained in:
89
ReleaseUpgradeOne.sh
Normal file
89
ReleaseUpgradeOne.sh
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
|
||||
#####################################
|
||||
# ProxMox update tools #
|
||||
# Upgrade one CT/VM OS release #
|
||||
# @author: Bram Prieshof #
|
||||
#####################################
|
||||
|
||||
#Load functions
|
||||
source $(dirname $0)/functions.sh
|
||||
|
||||
#InputChecks
|
||||
## Check if exists
|
||||
if [ -z ${1+x} ]; then echo "No input, usage: $0 <CT/VM-ID>"; exit; fi
|
||||
## Check if valid (number/integer)
|
||||
if [ -z "${1##*[!0-9]*}" ]; then echo "Invalid ID, usage: $0 <CT/VM-ID>"; exit; fi
|
||||
|
||||
#Setup Vars, since a seemingly valid id is given
|
||||
ID=$1
|
||||
VMS=$(qm list | tail -n+2 | awk '{print $1}')
|
||||
CTS=$(pct list | tail -n+2 | awk '{print $1}')
|
||||
ALLIDS=(${CTS[@]} ${VMS[@]})
|
||||
|
||||
## Check if ID exists
|
||||
for ExistingID in "${ALLIDS[@]}"; do
|
||||
if [ $ExistingID -eq $ID ]; then
|
||||
IdExists=true
|
||||
break
|
||||
fi
|
||||
IdExists=false
|
||||
done
|
||||
if ! $IdExists; then echo "This ID does not exist"; exit; fi
|
||||
|
||||
#Check type of ID
|
||||
if [[ $VMS =~ $ID ]];then
|
||||
TYPE=VM;
|
||||
DIST=$(qm guest exec $VMID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release | jq '.["out-data"]')
|
||||
fi
|
||||
if [[ $CTS =~ $ID ]]; then
|
||||
TYPE=CT
|
||||
DIST=$(pct exec $CTID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
|
||||
fi
|
||||
|
||||
#Check if VM/CT is running
|
||||
if ! $($TYPE-State $ID); then echo "This ID is not runnig"; exit; fi
|
||||
|
||||
#Check wich distro the CT/VM is running
|
||||
if [[ "${DIST}" == *"debian"* ]]; then
|
||||
#Ask the wanted Debian version
|
||||
DoDebianReleaseUpdate=true
|
||||
DoAlpineReleaseUpdate=false
|
||||
|
||||
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
|
||||
elif [[ "${DIST}" == *"alpine"* ]]; then
|
||||
#Ask the wanted Alpine version
|
||||
DoAlpineReleaseUpdate=true
|
||||
DoDebianReleaseUpdate=false
|
||||
|
||||
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
|
||||
else
|
||||
echo "Warning: Release upgrade are supported for this distro"
|
||||
exit
|
||||
fi
|
||||
|
||||
$TYPE-UpgradeRelease $ID
|
||||
Reference in New Issue
Block a user