Added check for state of VM/CT to avoid errors
This commit is contained in:
28
functions.sh
28
functions.sh
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user