mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 11:25:49 +00:00
Update power.sh
This commit is contained in:
parent
9a9832f57b
commit
8b53d3c8b7
1 changed files with 31 additions and 32 deletions
63
src/power.sh
63
src/power.sh
|
|
@ -12,9 +12,6 @@ QEMU_LOG="/run/shm/qemu.log"
|
|||
QEMU_OUT="/run/shm/qemu.out"
|
||||
QEMU_END="/run/shm/qemu.end"
|
||||
|
||||
BIOS_LINE="Booting from Hard Disk..."
|
||||
BOOT_LINE="Windows Boot Manager"
|
||||
|
||||
rm -f /run/shm/qemu.*
|
||||
touch "$QEMU_LOG"
|
||||
|
||||
|
|
@ -25,6 +22,29 @@ _trap() {
|
|||
done
|
||||
}
|
||||
|
||||
ready() {
|
||||
|
||||
[ -f "$STORAGE/windows.boot" ] && return 0
|
||||
[ ! -f "$QEMU_PTY" ] && return 1
|
||||
|
||||
if [ -f "$STORAGE/windows.old" ]; then
|
||||
local last
|
||||
local bios="Booting from Hard Disk..."
|
||||
last=$(grep "^B.*" "$QEMU_PTY" | tail -1)
|
||||
if [[ "${last,,}" == "${bios,,}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
|
||||
local line="Windows Boot Manager"
|
||||
if grep -Fq "$line" "$QEMU_PTY"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
finish() {
|
||||
|
||||
local pid
|
||||
|
|
@ -43,21 +63,11 @@ finish() {
|
|||
done
|
||||
fi
|
||||
|
||||
if [ -f "$STORAGE/$BASE" ] && [ ! -f "$STORAGE/windows.boot" ]; then
|
||||
if [ -f "$QEMU_PTY" ]; then
|
||||
if [ ! -f "$STORAGE/windows.old" ]; then
|
||||
if grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
||||
rm -f "$STORAGE/$BASE"
|
||||
touch "$STORAGE/windows.boot"
|
||||
fi
|
||||
else
|
||||
local last
|
||||
last=$(tail -n 1 "$QEMU_PTY")
|
||||
if [[ "${last,,}" == "${BIOS_LINE,,}" ]]; then
|
||||
rm -f "$STORAGE/$BASE"
|
||||
touch "$STORAGE/windows.boot"
|
||||
fi
|
||||
fi
|
||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$STORAGE/$BASE" ]; then
|
||||
# Remove CD-ROM ISO after install
|
||||
if ready; then
|
||||
rm -f "$STORAGE/$BASE"
|
||||
touch "$STORAGE/windows.boot"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -137,20 +147,9 @@ _graceful_shutdown() {
|
|||
finish "$code" && return "$code"
|
||||
fi
|
||||
|
||||
local abort="Cannot send ACPI signal during Windows setup, aborting..."
|
||||
|
||||
if [ -f "$QEMU_PTY" ] && [ ! -f "$STORAGE/windows.boot" ]; then
|
||||
if [ ! -f "$STORAGE/windows.old" ]; then
|
||||
if ! grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
||||
info "$abort" && finish "$code" && return "$code"
|
||||
fi
|
||||
else
|
||||
local last
|
||||
last=$(tail -n 1 "$QEMU_PTY")
|
||||
if [[ "${last,,}" != "${BIOS_LINE,,}" ]]; then
|
||||
info "$abort" && finish "$code" && return "$code"
|
||||
fi
|
||||
fi
|
||||
if ! ready; then
|
||||
info "Cannot send ACPI signal during Windows setup, aborting..."
|
||||
finish "$code" && return "$code"
|
||||
fi
|
||||
|
||||
# Send ACPI shutdown signal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue