diff --git a/remote-shutdown b/remote-shutdown new file mode 100755 index 0000000..37cfd03 --- /dev/null +++ b/remote-shutdown @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +sessions=$(w | sed '1,2d' | wc -l) + +if [ $sessions -gt 0 ] ; then + echo Users still logged in! Not continuing + exit 1 +fi + +# virsh inserts an additional newline, so this is the number of +# running VMs + 1 +running_vms=$(virsh -c qemu:///system list --state-running --uuid | wc -l) + +if [ $running_vms -gt 1 ] ; then + echo VMs still running! Not continuing + exit 1 +fi + +poweroff