Added PostUpgrade tasks for Debian 13 and Alpine 3.23, refactored Type Detection of scripts tageting one system
This commit is contained in:
24
UpdateOne.sh
24
UpdateOne.sh
@@ -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,9 +31,23 @@ IdExists=false
|
||||
done
|
||||
if ! $IdExists; then echo "This ID does not exist"; exit; fi
|
||||
|
||||
#Check type of ID
|
||||
if [[ $VMS =~ $ID ]]; then TYPE=VM; fi
|
||||
if [[ $CTS =~ $ID ]]; then TYPE=CT; 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
|
||||
|
||||
Reference in New Issue
Block a user