Added check for state of VM/CT to avoid errors

This commit is contained in:
2022-08-30 21:34:58 +02:00
parent 2b88178caf
commit 9e8b4a89fd
3 changed files with 37 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ while true; do
UpdatePKG=true
UpdateAPP=true
break;;
* ) echo "Please answer with (A)ll, (C)T`s or (V)M`s.";;
* ) echo "Please answer with (P)ackages, (A)pplications or (B)oth.";;
esac
done
@@ -66,6 +66,8 @@ if $UpdateCT; then
for CTID in $(pct list | tail -n+2 | awk '{print $1}'); 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"
if $UpdatePKG; then
CT-UpdatePackages $CTID | tee "$LogDir"/"$CTID"_Pkgs.log
@@ -79,8 +81,10 @@ fi
#VM Updates
if $UpdateVM; then
for VMID in $(qm list | tail -n+2 | awk '{print $1}'); do
#Skip CT if in ExcludeList
#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"
if $UpdatePKG; then
VM-UpdatePackages $VMID | tee "$LogDir"/"$VMID"_Pkgs.log