add remote-shutdown script

This commit is contained in:
joachimschmidt557 2023-03-25 00:00:06 +01:00
parent 3c13a0d0fd
commit ccd9c069f4
No known key found for this signature in database
GPG key ID: E0B575BE2884ACC5

19
remote-shutdown Executable file
View file

@ -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