diff options
author | Sam Chudnick <sam@chudnick.com> | 2022-02-12 17:54:06 -0500 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2022-02-12 17:54:06 -0500 |
commit | b0a2c1c5800c30ecf37311885ce11f244102873e (patch) | |
tree | 49329a7af06795ff5fb16479d7c3dfe3441555ee /.local/bin/stop-vm | |
parent | a7ec0d3b3e49837c52051de489b118b650bb2bf0 (diff) |
Bunch of changes
Diffstat (limited to '.local/bin/stop-vm')
-rwxr-xr-x | .local/bin/stop-vm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.local/bin/stop-vm b/.local/bin/stop-vm new file mode 100755 index 0000000..6c92250 --- /dev/null +++ b/.local/bin/stop-vm | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/sh | ||
2 | # Stops domains given as arguments | ||
3 | |||
4 | opts=$(getopt -o 'as' -l 'all,save' -- "$@") | ||
5 | eval set -- "$opts" | ||
6 | all=0 | ||
7 | save=0 | ||
8 | while true | ||
9 | do | ||
10 | case $1 in | ||
11 | '-a'|'--all') all=1; shift; continue ;; | ||
12 | '-s'|'--save') save=1; shift; continue ;; | ||
13 | '--') shift; break;; | ||
14 | esac | ||
15 | done | ||
16 | |||
17 | [ $all -eq 1 ] && domains="$(virsh list | grep running | awk '{print $2}')" || domains="$@" | ||
18 | for domain in $domains | ||
19 | do | ||
20 | [ $save -eq 1 ] && virsh managedsave $domain || virsh shutdown $domain | ||
21 | done | ||