diff --git a/shutdown-all-vms.sh b/shutdown-all-vms.sh index d439f43..c833c5f 100644 --- a/shutdown-all-vms.sh +++ b/shutdown-all-vms.sh @@ -1,7 +1,7 @@ #!/bin/bash # Script to try to gracefully shut down all running VMs on a Proxmox host, before then force stopping them. # Running as a sub-script of apcupsd's doshutdown function to ensure that VMs are shut down before the host is powered off. -#v1.1.1 +#v1.1.2 # Get a list of running VMs vmlist=$(qm list | grep running | awk '{print $1}') @@ -12,22 +12,24 @@ echo "VM(s) $vmlist" echo "Container(s) $lxclist" # Loop through the list and force shutdown each VM -echo "Stopping VM(s)..." +echo "Shutting down VM(s)..." for vmid in $vmlist do echo "Sending shutown command to VM $vmid" qm shutdown $vmid & + sleep 2 done -echo "Stopping container(s)..." +echo "Shutting down container(s)..." for lxcid in $lxclist do echo "Sending shutown command to container $lxcid" pct shutdown $lxcid & + sleep 2 done # Wait for 2.5 minutes to allow VMs to shut down -echo -e "\nWating for shutdowns to complete." +echo -e "\nWating 2.5 minutes for shutdowns to complete." sleep 150 # Get a list of running VMs again @@ -55,4 +57,5 @@ if [[ -n "$vmlist" || -n "$lxclist" ]]; then fi # Exit with success +echo -e "\nShutdowns complete." exit 0 \ No newline at end of file