From 7031f66c13c181af3f20ba8e14a9909af93ba563 Mon Sep 17 00:00:00 2001 From: Kroese Date: Thu, 25 Jan 2024 03:07:45 +0100 Subject: [PATCH] Update power.sh --- src/power.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/power.sh b/src/power.sh index b1a6cc9..73c00de 100644 --- a/src/power.sh +++ b/src/power.sh @@ -116,17 +116,17 @@ _graceful_shutdown() { finish "$code" && return "$code" fi - if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then - if ! grep -Fq "Windows Boot Manager" "$QEMU_PTY"; then - if [ ! -f "$STORAGE/windows.bios" ]; then + local remove_iso="" + + if [ ! -f "$STORAGE/windows.bios" ]; then + if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then + if grep -Fq "Windows Boot Manager" "$QEMU_PTY"; then + remove_iso="y" + else info "Cannot send ACPI signal during Windows setup, aborting..." finish "$code" && return "$code" fi fi - if [ -f "$STORAGE/$BASE" ] && [ ! -f "$STORAGE/windows.bios" ]; then - rm -f "$STORAGE/$BASE" - touch "$STORAGE/windows.boot" - fi fi # Send ACPI shutdown signal @@ -151,6 +151,11 @@ _graceful_shutdown() { if [ "$cnt" -ge "$QEMU_TIMEOUT" ]; then error "Shutdown timeout reached, aborting..." + else + if [ -f "$STORAGE/$BASE" ] && [ -n "$remove_iso" ]; then + rm -f "$STORAGE/$BASE" + touch "$STORAGE/windows.boot" + fi fi finish "$code" && return "$code"