summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/check-repos10
-rwxr-xr-x.local/bin/kill-libvirtd22
-rwxr-xr-x.local/bin/start-vm9
-rwxr-xr-x.local/bin/stop-vm21
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
3cd $HOME/repos
4for repo in $(ls)
5do
6 [ -d $repo/.git ] && echo $repo && \
7 echo "------------------------------------------------------" && \
8 git --git-dir=$repo/.git --work-tree=$repo status 2>/dev/null && \
9 echo "------------------------------------------------------"
10done
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
5rundoms="$(virsh list | grep running | awk '{print $2}')"
6for dom in $rundoms
7do
8 virsh managedsave $dom
9done
10
11# Stop network
12virsh net-destroy default
13
14# Stop libvirtd
15sudo systemctl stop libvirtd >/dev/null
16sudo systemctl stop libvirtd-ro.socket >/dev/null
17sudo systemctl stop libvirtd-admin.socket >/dev/null
18sudo systemctl stop libvirtd.socket >/dev/null
19sudo systemctl stop virtlogd >/dev/null
20sudo systemctl stop virtlogd-admin.socket >/dev/null
21sudo systemctl stop virtlogd.socket >/dev/null
22sudo 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
4pgrep libvirtd >/dev/null || sudo systemctl start libvirtd
5virsh net-start default
6for domain in "$@"
7do
8 virsh start $domain
9done
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
4opts=$(getopt -o 'as' -l 'all,save' -- "$@")
5eval set -- "$opts"
6all=0
7save=0
8while true
9do
10 case $1 in
11 '-a'|'--all') all=1; shift; continue ;;
12 '-s'|'--save') save=1; shift; continue ;;
13 '--') shift; break;;
14 esac
15done
16
17[ $all -eq 1 ] && domains="$(virsh list | grep running | awk '{print $2}')" || domains="$@"
18for domain in $domains
19do
20 [ $save -eq 1 ] && virsh managedsave $domain || virsh shutdown $domain
21done