diff --git a/.scripts/_flameboi/virt/ensure-pool-online-status.sh b/.scripts/_flameboi/virt/ensure-pool-online-status.sh new file mode 100755 index 0000000..775844f --- /dev/null +++ b/.scripts/_flameboi/virt/ensure-pool-online-status.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +ALL_OK=false +ALL_VIRT_POOLS=("default" "ISOs") + +for POOL in "${ALL_VIRT_POOLS[@]}"; do + POOL_OK=false + + while [[ "$POOL_OK" == "false" ]]; do + virsh pool-info --pool "$POOL" | grep "State: *running" > /dev/null + + if [[ $? -ne 0 ]]; then + echo "$POOL: not running" + systemctl restart libvirtd && POOL_OK=true + else + echo "$POOL: OK" + POOL_OK=true + fi + done +done diff --git a/_OTHER/flameboi/etc/systemd/system/virt-pool-online.service b/_OTHER/flameboi/etc/systemd/system/virt-pool-online.service new file mode 100644 index 0000000..ff1171b --- /dev/null +++ b/_OTHER/flameboi/etc/systemd/system/virt-pool-online.service @@ -0,0 +1,9 @@ +[Unit] +Description=Ensure that the VM pools are available + +[Service] +ExecStart=/usr/bin/bash /home/pratham/.scripts/_flameboi/virt/ensure-pool-online-status.sh +Type=simple + +[Install] +WantedBy=multi-user.target