mirror of
https://github.com/dockur/windows.git
synced 2026-08-03 12:37:20 +01:00
feat: Improve startup detection (#2017)
This commit is contained in:
+1
-1
@@ -63,7 +63,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pid=$!
|
pid=$!
|
||||||
( sleep 30; boot ) &
|
waitForBoot "$pid" 30 &
|
||||||
|
|
||||||
rc=0
|
rc=0
|
||||||
wait "$pid" || rc=$?
|
wait "$pid" || rc=$?
|
||||||
|
|||||||
+59
-15
@@ -15,36 +15,80 @@ CONSOLE_PID="$QEMU_DIR/console.pid"
|
|||||||
CONSOLE_SOCKET="$QEMU_DIR/console.sock"
|
CONSOLE_SOCKET="$QEMU_DIR/console.sock"
|
||||||
QEMU_START_PID="$QEMU_DIR/qemu.start.pid"
|
QEMU_START_PID="$QEMU_DIR/qemu.start.pid"
|
||||||
|
|
||||||
bootFailed() {
|
bootStatus() {
|
||||||
|
|
||||||
local fail=""
|
[ ! -s "$QEMU_PTY" ] && return 1
|
||||||
|
|
||||||
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
||||||
grep -Fq "No bootable device." "$QEMU_PTY" && fail="y"
|
grep -Fq \
|
||||||
grep -Fq "BOOTMGR is missing" "$QEMU_PTY" && fail="y"
|
-e "No bootable device." \
|
||||||
|
-e "BOOTMGR is missing" \
|
||||||
|
-e "Boot failed: not a bootable disk" \
|
||||||
|
-e "Boot failed: could not read the boot disk" \
|
||||||
|
"$QEMU_PTY" && return 2
|
||||||
|
|
||||||
|
grep -Eq '^Booting from (Hard|DVD/CD)' "$QEMU_PTY"
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$fail" ]
|
grep -Fq "UEFI Interactive Shell" "$QEMU_PTY" && return 2
|
||||||
|
|
||||||
|
local last
|
||||||
|
last=$(grep -E \
|
||||||
|
'BdsDxe: starting Boot[[:xdigit:]]{4} ' \
|
||||||
|
"$QEMU_PTY" | tail -1)
|
||||||
|
|
||||||
|
[ -z "$last" ] && return 1
|
||||||
|
|
||||||
|
grep -Eq \
|
||||||
|
-e '"Windows Boot Manager"' \
|
||||||
|
-e '"UEFI QEMU .*DVD-ROM' \
|
||||||
|
-e 'CDROM\(' \
|
||||||
|
-e 'USB\(' \
|
||||||
|
<<< "$last"
|
||||||
}
|
}
|
||||||
|
|
||||||
boot() {
|
waitForBoot() {
|
||||||
|
|
||||||
[ -f "$QEMU_END" ] && return 0
|
local pid="$1"
|
||||||
|
local timeout="${2:-30}"
|
||||||
|
local deadline=$((SECONDS + timeout))
|
||||||
|
local screen="visit http://127.0.0.1:$WEB_PORT/ to view the screen..."
|
||||||
|
|
||||||
if [ -s "$QEMU_PTY" ]; then
|
while isAlive "$pid"; do
|
||||||
if [ "$(stat -c%s "$QEMU_PTY")" -gt 7 ]; then
|
|
||||||
if ! bootFailed; then
|
|
||||||
|
|
||||||
|
if bootStatus; then
|
||||||
|
local status=0
|
||||||
|
else
|
||||||
|
local status=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$status" in
|
||||||
|
0)
|
||||||
if [[ "${DISPLAY,,}" == "web" ]] && ! disabled "${WEB:-Y}"; then
|
if [[ "${DISPLAY,,}" == "web" ]] && ! disabled "${WEB:-Y}"; then
|
||||||
info "$(app) started successfully, visit http://127.0.0.1:$WEB_PORT/ to view the screen..."
|
info "$(app) started successfully, $screen"
|
||||||
else
|
else
|
||||||
info "$(app) started successfully."
|
info "$(app) started successfully."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0 ;;
|
||||||
fi
|
2)
|
||||||
fi
|
if [[ "${DISPLAY,,}" == "web" ]] && ! disabled "${WEB:-Y}"; then
|
||||||
fi
|
warn "$(app) could not boot, $screen"
|
||||||
|
else
|
||||||
|
warn "$(app) could not boot."
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
(( SECONDS >= deadline )) && break
|
||||||
|
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
|
||||||
|
! isAlive "$pid" && return 0
|
||||||
|
[ -f "$QEMU_END" ] && return 0
|
||||||
|
|
||||||
error "Timeout while waiting for QEMU to boot the machine, aborting..."
|
error "Timeout while waiting for QEMU to boot the machine, aborting..."
|
||||||
terminateQemu
|
terminateQemu
|
||||||
|
|||||||
Reference in New Issue
Block a user