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 | |
parent | a7ec0d3b3e49837c52051de489b118b650bb2bf0 (diff) |
Bunch of changes
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/check-repos | 10 | ||||
-rwxr-xr-x | .local/bin/kill-libvirtd | 22 | ||||
-rwxr-xr-x | .local/bin/start-vm | 9 | ||||
-rwxr-xr-x | .local/bin/stop-vm | 21 |
4 files changed, 62 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd $HOME/repos | ||
4 | for repo in $(ls) | ||
5 | do | ||
6 | [ -d $repo/.git ] && echo $repo && \ | ||
7 | echo "------------------------------------------------------" && \ | ||
8 | git --git-dir=$repo/.git --work-tree=$repo status 2>/dev/null && \ | ||
9 | echo "------------------------------------------------------" | ||
10 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # Stop all running domains and networks, and then stop all libvirtd daemons | ||
3 | |||
4 | # Save running domains | ||
5 | rundoms="$(virsh list | grep running | awk '{print $2}')" | ||
6 | for dom in $rundoms | ||
7 | do | ||
8 | virsh managedsave $dom | ||
9 | done | ||
10 | |||
11 | # Stop network | ||
12 | virsh net-destroy default | ||
13 | |||
14 | # Stop libvirtd | ||
15 | sudo systemctl stop libvirtd >/dev/null | ||
16 | sudo systemctl stop libvirtd-ro.socket >/dev/null | ||
17 | sudo systemctl stop libvirtd-admin.socket >/dev/null | ||
18 | sudo systemctl stop libvirtd.socket >/dev/null | ||
19 | sudo systemctl stop virtlogd >/dev/null | ||
20 | sudo systemctl stop virtlogd-admin.socket >/dev/null | ||
21 | sudo systemctl stop virtlogd.socket >/dev/null | ||
22 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # Starts libvirtd, default network, and optionally any domains given as arguments | ||
3 | |||
4 | pgrep libvirtd >/dev/null || sudo systemctl start libvirtd | ||
5 | virsh net-start default | ||
6 | for domain in "$@" | ||
7 | do | ||
8 | virsh start $domain | ||
9 | 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 @@ | |||
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 | ||