From b0a2c1c5800c30ecf37311885ce11f244102873e Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sat, 12 Feb 2022 17:54:06 -0500 Subject: Bunch of changes --- .local/bin/stop-vm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 .local/bin/stop-vm (limited to '.local/bin/stop-vm') 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 @@ +#!/bin/sh +# Stops domains given as arguments + +opts=$(getopt -o 'as' -l 'all,save' -- "$@") +eval set -- "$opts" +all=0 +save=0 +while true +do + case $1 in + '-a'|'--all') all=1; shift; continue ;; + '-s'|'--save') save=1; shift; continue ;; + '--') shift; break;; + esac +done + +[ $all -eq 1 ] && domains="$(virsh list | grep running | awk '{print $2}')" || domains="$@" +for domain in $domains +do + [ $save -eq 1 ] && virsh managedsave $domain || virsh shutdown $domain +done -- cgit v1.2.3