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/check-repos | 10 ++++++++++ .local/bin/kill-libvirtd | 22 ++++++++++++++++++++++ .local/bin/start-vm | 9 +++++++++ .local/bin/stop-vm | 21 +++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100755 .local/bin/check-repos create mode 100755 .local/bin/kill-libvirtd create mode 100755 .local/bin/start-vm create mode 100755 .local/bin/stop-vm (limited to '.local/bin') diff --git a/.local/bin/check-repos b/.local/bin/check-repos new file mode 100755 index 0000000..d528ce6 --- /dev/null +++ b/.local/bin/check-repos @@ -0,0 +1,10 @@ +#!/bin/sh + +cd $HOME/repos +for repo in $(ls) +do + [ -d $repo/.git ] && echo $repo && \ + echo "------------------------------------------------------" && \ + git --git-dir=$repo/.git --work-tree=$repo status 2>/dev/null && \ + echo "------------------------------------------------------" +done diff --git a/.local/bin/kill-libvirtd b/.local/bin/kill-libvirtd new file mode 100755 index 0000000..2ea802d --- /dev/null +++ b/.local/bin/kill-libvirtd @@ -0,0 +1,22 @@ +#!/bin/sh +# Stop all running domains and networks, and then stop all libvirtd daemons + +# Save running domains +rundoms="$(virsh list | grep running | awk '{print $2}')" +for dom in $rundoms +do + virsh managedsave $dom +done + +# Stop network +virsh net-destroy default + +# Stop libvirtd +sudo systemctl stop libvirtd >/dev/null +sudo systemctl stop libvirtd-ro.socket >/dev/null +sudo systemctl stop libvirtd-admin.socket >/dev/null +sudo systemctl stop libvirtd.socket >/dev/null +sudo systemctl stop virtlogd >/dev/null +sudo systemctl stop virtlogd-admin.socket >/dev/null +sudo systemctl stop virtlogd.socket >/dev/null +sudo systemctl stop systemd-machined >/dev/null diff --git a/.local/bin/start-vm b/.local/bin/start-vm new file mode 100755 index 0000000..5ffea03 --- /dev/null +++ b/.local/bin/start-vm @@ -0,0 +1,9 @@ +#!/bin/sh +# Starts libvirtd, default network, and optionally any domains given as arguments + +pgrep libvirtd >/dev/null || sudo systemctl start libvirtd +virsh net-start default +for domain in "$@" +do + virsh start $domain +done 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