add remote-shutdown script
This commit is contained in:
parent
3c13a0d0fd
commit
ccd9c069f4
1 changed files with 19 additions and 0 deletions
19
remote-shutdown
Executable file
19
remote-shutdown
Executable 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue