mirror of
https://github.com/dockur/windows-arm.git
synced 2024-07-07 22:21:56 +00:00
feat: Boot detection (#6)
This commit is contained in:
parent
1c2c8c5e14
commit
d5f4b4784b
21
src/power.sh
21
src/power.sh
|
@ -11,6 +11,7 @@ QEMU_PTY="/run/shm/qemu.pty"
|
|||
QEMU_LOG="/run/shm/qemu.log"
|
||||
QEMU_OUT="/run/shm/qemu.out"
|
||||
QEMU_END="/run/shm/qemu.end"
|
||||
BOOT_LINE="starting Boot0002"
|
||||
|
||||
rm -f /run/shm/qemu.*
|
||||
touch "$QEMU_LOG"
|
||||
|
@ -40,6 +41,15 @@ finish() {
|
|||
done
|
||||
fi
|
||||
|
||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then
|
||||
if grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
||||
if [ -f "$STORAGE/$BASE" ]; then
|
||||
rm -f "$STORAGE/$BASE"
|
||||
touch "$STORAGE/windows.boot"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
pid="/var/run/tpm.pid"
|
||||
[ -f "$pid" ] && pKill "$(<"$pid")"
|
||||
|
||||
|
@ -116,12 +126,8 @@ _graceful_shutdown() {
|
|||
finish "$code" && return "$code"
|
||||
fi
|
||||
|
||||
local remove_iso=""
|
||||
|
||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then
|
||||
if grep -Fq "starting Boot0002" "$QEMU_PTY"; then
|
||||
[ -f "$STORAGE/$BASE" ] && remove_iso="y"
|
||||
else
|
||||
if ! grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
||||
info "Cannot send ACPI signal during Windows setup, aborting..."
|
||||
finish "$code" && return "$code"
|
||||
fi
|
||||
|
@ -149,11 +155,6 @@ _graceful_shutdown() {
|
|||
|
||||
if [ "$cnt" -ge "$QEMU_TIMEOUT" ]; then
|
||||
error "Shutdown timeout reached, aborting..."
|
||||
else
|
||||
if [ -n "$remove_iso" ]; then
|
||||
rm -f "$STORAGE/$BASE"
|
||||
touch "$STORAGE/windows.boot"
|
||||
fi
|
||||
fi
|
||||
|
||||
finish "$code" && return "$code"
|
||||
|
|
Loading…
Reference in a new issue