safeguard: check Docker/VM Manager enabled before acting

common.sh: add is_docker_enabled() and is_vm_manager_enabled() helpers
reading /boot/config/docker.cfg and /boot/config/domain.cfg.

docker_watchdog: exit cleanly if Docker not enabled in Unraid settings.
stability_watchdog: skip Docker daemon check and Docker container stop
if Docker not enabled; skip virsh VM shutdown if VM Manager not enabled.
server_reboot: skip VM shutdown and libvirt stop if VM Manager not enabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-31 15:18:58 -04:00
co-authored by Claude Sonnet 4.6
parent fdba23c32d
commit 46b27f609a
4 changed files with 35 additions and 6 deletions
+8 -2
View File
@@ -252,7 +252,7 @@ fi
# ==============================================================================================
# ━━━ Graceful VM Shutdown ━━━
# ==============================================================================================
if command -v virsh >/dev/null 2>&1; then
if is_vm_manager_enabled && command -v virsh >/dev/null 2>&1; then
VM_LIST=$(virsh list --name 2>/dev/null | grep -v "^$" || true)
if [[ -n "$VM_LIST" ]]; then
echo ""
@@ -272,7 +272,11 @@ if command -v virsh >/dev/null 2>&1; then
log "Waiting ${VM_WAIT}s for VMs to shut down..."
sleep "$VM_WAIT"
fi
else
log "VM Manager enabled but no VMs running — skipping shutdown"
fi
else
log "VM Manager not enabled — skipping VM shutdown"
fi
# ==============================================================================================
@@ -280,7 +284,9 @@ fi
# ==============================================================================================
echo ""
echo "━━━ $ICON_GEAR Stop VM Manager ━━━"
if [[ "$DRY_RUN" == true ]]; then
if ! is_vm_manager_enabled; then
log "VM Manager not enabled — skipping"
elif [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — would stop VM Manager (libvirt)"
else
if /etc/rc.d/rc.libvirt stop >/dev/null 2>&1; then