Added PostUpgrade tasks for Debian 13 and Alpine 3.23, refactored Type Detection of scripts tageting one system
This commit is contained in:
@@ -17,8 +17,8 @@ if [ -z "${1##*[!0-9]*}" ]; then echo "Invalid ID, usage: $0 <CT/VM-ID>"; exit;
|
||||
|
||||
#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}')
|
||||
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
|
||||
@@ -31,17 +31,30 @@ IdExists=false
|
||||
done
|
||||
if ! $IdExists; then echo "This ID does not exist"; exit; fi
|
||||
|
||||
#Check type of ID
|
||||
if [[ $VMS =~ $ID ]];then
|
||||
TYPE=VM;
|
||||
if ! $(VM-State $ID); then echo "This ID is not runnig"; exit; fi
|
||||
#Determine id type
|
||||
for ArrayID in "${CTS[@]}"; do
|
||||
if [ $ArrayID -eq $ID ]; then
|
||||
TYPE=CT
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for ArrayID in "${VMS[@]}"; do
|
||||
if [ ! -z ${TYPE+x} ]; then break; fi
|
||||
if [ $ArrayID -eq $ID ]; then
|
||||
TYPE=VM
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z ${TYPE+x} ]; then echo "The ID Type chould not be determind"; exit; fi
|
||||
|
||||
#Check if VM/CT is running
|
||||
if ! $($TYPE-State $ID); then echo "This ID is not runnig"; exit; fi
|
||||
|
||||
#Get distro type
|
||||
if [ "$TYPE" = "VM" ];then
|
||||
DIST=$(qm guest exec $ID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release | jq '.["out-data"]')
|
||||
fi
|
||||
if [[ $CTS =~ $ID ]]; then
|
||||
TYPE=CT
|
||||
#Check if CT is running
|
||||
if ! $(CT-State $ID); then echo "This ID is not runnig"; exit; fi
|
||||
#Get CT distro
|
||||
elif [ "$TYPE" = "CT" ]; then
|
||||
DIST=$(pct exec $ID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user