mirror of
https://github.com/dockur/windows.git
synced 2025-10-13 23:36:11 +01:00
feat: Monitor port is now configurable (#1451)
This commit is contained in:
parent
434bc11907
commit
29a9e2d68c
@ -3,7 +3,7 @@
|
|||||||
ARG VERSION_ARG="latest"
|
ARG VERSION_ARG="latest"
|
||||||
FROM scratch AS build-amd64
|
FROM scratch AS build-amd64
|
||||||
|
|
||||||
COPY --from=qemux/qemu:7.20 / /
|
COPY --from=qemux/qemu:7.21 / /
|
||||||
|
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG DEBCONF_NOWARNINGS="yes"
|
ARG DEBCONF_NOWARNINGS="yes"
|
||||||
|
12
src/power.sh
12
src/power.sh
@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
: "${QEMU_TIMEOUT:="110"}" # QEMU Termination timeout
|
||||||
|
|
||||||
# Configure QEMU for graceful shutdown
|
# Configure QEMU for graceful shutdown
|
||||||
|
|
||||||
QEMU_TERM=""
|
QEMU_TERM=""
|
||||||
QEMU_PORT=7100
|
|
||||||
QEMU_TIMEOUT=110
|
|
||||||
QEMU_DIR="/run/shm"
|
QEMU_DIR="/run/shm"
|
||||||
QEMU_PID="$QEMU_DIR/qemu.pid"
|
QEMU_PID="$QEMU_DIR/qemu.pid"
|
||||||
QEMU_PTY="$QEMU_DIR/qemu.pty"
|
QEMU_PTY="$QEMU_DIR/qemu.pty"
|
||||||
@ -139,7 +139,7 @@ terminal() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -c "$dev" ]; then
|
if [ ! -c "$dev" ]; then
|
||||||
dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000')
|
dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$MON_PORT" | tr -d '\000')
|
||||||
dev="${dev#*serial0}"
|
dev="${dev#*serial0}"
|
||||||
dev="${dev#*pty:}"
|
dev="${dev#*pty:}"
|
||||||
dev="${dev%%$'\n'*}"
|
dev="${dev%%$'\n'*}"
|
||||||
@ -188,7 +188,7 @@ _graceful_shutdown() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Send ACPI shutdown signal
|
# Send ACPI shutdown signal
|
||||||
echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null
|
echo 'system_powerdown' | nc -q 1 -w 1 localhost "$MON_PORT" > /dev/null
|
||||||
|
|
||||||
local cnt=0
|
local cnt=0
|
||||||
while [ "$cnt" -lt "$QEMU_TIMEOUT" ]; do
|
while [ "$cnt" -lt "$QEMU_TIMEOUT" ]; do
|
||||||
@ -203,7 +203,7 @@ _graceful_shutdown() {
|
|||||||
info "Waiting for Windows to shutdown... ($cnt/$QEMU_TIMEOUT)"
|
info "Waiting for Windows to shutdown... ($cnt/$QEMU_TIMEOUT)"
|
||||||
|
|
||||||
# Send ACPI shutdown signal
|
# Send ACPI shutdown signal
|
||||||
echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null
|
echo 'system_powerdown' | nc -q 1 -w 1 localhost "$MON_PORT" > /dev/null
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ _graceful_shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SERIAL="pty"
|
SERIAL="pty"
|
||||||
MONITOR="telnet:localhost:$QEMU_PORT,server,nowait,nodelay"
|
MONITOR="telnet:localhost:$MON_PORT,server,nowait,nodelay"
|
||||||
MONITOR+=" -daemonize -D $QEMU_LOG -pidfile $QEMU_PID"
|
MONITOR+=" -daemonize -D $QEMU_LOG -pidfile $QEMU_PID"
|
||||||
|
|
||||||
_trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT
|
_trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user