scripts/remote-shutdown
2023-03-25 00:00:06 +01:00

19 lines
407 B
Bash
Executable file

#!/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