Update power.sh

This commit is contained in:
Kroese 2024-02-06 03:43:39 +01:00 committed by GitHub
parent 893ca1f4cc
commit 58051bb914
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,8 +12,6 @@ QEMU_LOG="/run/shm/qemu.log"
QEMU_OUT="/run/shm/qemu.out" QEMU_OUT="/run/shm/qemu.out"
QEMU_END="/run/shm/qemu.end" QEMU_END="/run/shm/qemu.end"
BOOT_LINE="Windows Boot Manager"
rm -f /run/shm/qemu.* rm -f /run/shm/qemu.*
touch "$QEMU_LOG" touch "$QEMU_LOG"
@ -24,6 +22,19 @@ _trap() {
done done
} }
ready() {
[ -f "$STORAGE/windows.boot" ] && return 0
[ ! -f "$QEMU_PTY" ] && return 1
local line="Windows Boot Manager"
if grep -Fq "$line" "$QEMU_PTY"; then
return 0
fi
return 1
}
finish() { finish() {
local pid local pid
@ -42,12 +53,11 @@ finish() {
done done
fi fi
if [ -f "$STORAGE/$BASE" ] && [ ! -f "$STORAGE/windows.boot" ]; then if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$STORAGE/$BASE" ]; then
if [ -f "$QEMU_PTY" ]; then # Remove CD-ROM ISO after install
if grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then if ready; then
rm -f "$STORAGE/$BASE" rm -f "$STORAGE/$BASE"
touch "$STORAGE/windows.boot" touch "$STORAGE/windows.boot"
fi
fi fi
fi fi
@ -127,12 +137,9 @@ _graceful_shutdown() {
finish "$code" && return "$code" finish "$code" && return "$code"
fi fi
local abort="Cannot send ACPI signal during Windows setup, aborting..." if ! ready; then
info "Cannot send ACPI signal during Windows setup, aborting..."
if [ -f "$QEMU_PTY" ] && [ ! -f "$STORAGE/windows.boot" ]; then finish "$code" && return "$code"
if ! grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
info "$abort" && finish "$code" && return "$code"
fi
fi fi
# Send ACPI shutdown signal # Send ACPI shutdown signal