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

@@ -2,7 +2,7 @@
##########################
# ProxMox update tools #
# FUNCTIONS #
# FUNCTIONS #
# @author: Bram Prieshof #
##########################
@@ -91,4 +91,30 @@ VM-UpdateApplicatons () {
echo "Warning: application updates not enabled in $VMID"
#exit 102
fi
}
#Get state of CT as exitcode (0 when running 1 when stoped and 2 if CT is existend or other error occurs)
CT-State () {
if [ -z ${CTID+x} ]; then local CTID=$1;fi
case "$(pct status $CTID 2>&1)" in
*running* )
return 0;;
*stopped* )
return 1;;
* )
return 2;;
esac
}
#Get state of VM as exitcode (0 when running 1 when stoped and 2 if VM is existend or other error occurs)
VM-State (){
if [ -z ${VMID+x} ]; then local VMID=$1;fi
case "$(qm status $VMID 2>&1)" in
*running* )
return 0;;
*stopped* )
return 1;;
* )
return 2;;
esac
}