Ensure VM Auto-Start on SCALE

You could run some scheduled script, that starts a vm if it is set to autostart but is not currently running.

#!/usr/bin/bash
PATH=/bin:/usr/bin:/usr/local/bin
if [ $# -eq 0 ]; then
    echo "Syntax: `basename $0` vmname"
    exit 0
fi
VMNAME=$1

VMID=`midclt call vm.query | jq --arg vmname $VMNAME '.[] | select(.name == $vmname) | .id'`
VMS=`midclt call vm.query | jq --arg vmname $VMNAME '.[] | select(.name == $vmname) | .status.state'`
VMA=`midclt call vm.query | jq --arg vmname $VMNAME '.[] | select(.name == $vmname) | .autostart'`
if [[ "$VMA" != "true" ]]
then
     echo "VM is not on autostart."
     exit 0
fi
if [[ "$VMS" == '"STOPPED"' ]]
then
    midclt call vm.start $VMID
    echo "Watchdog starting '$VMNAME': id=$VMID"
    exit 1
else
   echo "VM is already running."
   exit 0
fi