feat: Detect Windows boot manager (#7)
This commit is contained in:
parent
d5f4b4784b
commit
b0eddb29c4
4 changed files with 32 additions and 23 deletions
|
@ -3,17 +3,17 @@ set -Eeuo pipefail
|
||||||
|
|
||||||
: "${MANUAL:=""}"
|
: "${MANUAL:=""}"
|
||||||
: "${DETECTED:=""}"
|
: "${DETECTED:=""}"
|
||||||
: "${VERSION:="win11arm"}"
|
: "${VERSION:="win11arm64"}"
|
||||||
|
|
||||||
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
||||||
VERSION="${VERSION:1:-1}"
|
VERSION="${VERSION:1:-1}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "${VERSION,,}" == "11" ]] && VERSION="win11arm"
|
[[ "${VERSION,,}" == "11" ]] && VERSION="win11arm64"
|
||||||
[[ "${VERSION,,}" == "win11" ]] && VERSION="win11arm"
|
[[ "${VERSION,,}" == "win11" ]] && VERSION="win11arm64"
|
||||||
|
|
||||||
[[ "${VERSION,,}" == "10" ]] && VERSION="win10arm"
|
[[ "${VERSION,,}" == "10" ]] && VERSION="win10arm64"
|
||||||
[[ "${VERSION,,}" == "win10" ]] && VERSION="win10arm"
|
[[ "${VERSION,,}" == "win10" ]] && VERSION="win10arm64"
|
||||||
|
|
||||||
CUSTOM="custom.iso"
|
CUSTOM="custom.iso"
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ getVersion() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local detected=""
|
local detected=""
|
||||||
|
|
||||||
[[ "${name,,}" == *"windows 11"* ]] && detected="win11arm"
|
[[ "${name,,}" == *"windows 11"* ]] && detected="win11arm64"
|
||||||
[[ "${name,,}" == *"windows 10"* ]] && detected="win10arm"
|
[[ "${name,,}" == *"windows 10"* ]] && detected="win10arm64"
|
||||||
|
|
||||||
echo "$detected"
|
echo "$detected"
|
||||||
return 0
|
return 0
|
||||||
|
@ -235,10 +235,10 @@ getESD() {
|
||||||
local winCatalog size
|
local winCatalog size
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
win11arm)
|
win11arm64)
|
||||||
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
|
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
|
||||||
;;
|
;;
|
||||||
win10arm)
|
win10arm64)
|
||||||
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -407,10 +407,10 @@ extractESD() {
|
||||||
local edition imageIndex imageEdition
|
local edition imageIndex imageEdition
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
win11arm)
|
win11arm64)
|
||||||
edition="11 pro"
|
edition="11 pro"
|
||||||
;;
|
;;
|
||||||
win10arm)
|
win10arm64)
|
||||||
edition="10 pro"
|
edition="10 pro"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
33
src/power.sh
33
src/power.sh
|
@ -11,7 +11,6 @@ QEMU_PTY="/run/shm/qemu.pty"
|
||||||
QEMU_LOG="/run/shm/qemu.log"
|
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="starting Boot0002"
|
|
||||||
|
|
||||||
rm -f /run/shm/qemu.*
|
rm -f /run/shm/qemu.*
|
||||||
touch "$QEMU_LOG"
|
touch "$QEMU_LOG"
|
||||||
|
@ -23,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
|
||||||
|
@ -41,12 +53,11 @@ finish() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then
|
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$STORAGE/$BASE" ]; then
|
||||||
if grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
# Remove CD-ROM ISO after install
|
||||||
if [ -f "$STORAGE/$BASE" ]; 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
|
||||||
|
|
||||||
|
@ -126,11 +137,9 @@ _graceful_shutdown() {
|
||||||
finish "$code" && return "$code"
|
finish "$code" && return "$code"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$QEMU_PTY" ]; then
|
if ! ready; then
|
||||||
if ! grep -Fq "$BOOT_LINE" "$QEMU_PTY"; then
|
info "Cannot send ACPI signal during Windows setup, aborting..."
|
||||||
info "Cannot send ACPI signal during Windows setup, aborting..."
|
finish "$code" && return "$code"
|
||||||
finish "$code" && return "$code"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send ACPI shutdown signal
|
# Send ACPI shutdown signal
|
||||||
|
|
Loading…
Reference in a new issue