From 131fa1379b8783beb51e424c2dc7b5df485eb96c Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 14 Jan 2024 20:32:24 +0100 Subject: [PATCH] feat: Windows 11 support (#6) --- Dockerfile | 8 +++++++- src/entry.sh | 3 +++ src/install.sh | 31 ++++++++++++++++++------------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53b3a29..632a2cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,17 +8,23 @@ RUN apt-get update \ && apt-get --no-install-recommends -y install \ curl \ novnc \ + swtpm \ + p7zip-full \ + genisoimage \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY ./src /run/ + ADD https://raw.githubusercontent.com/ElliotKillick/Mido/main/Mido.sh /run/mido.sh +ADD https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso /run/drivers.iso + RUN chmod +x /run/*.sh EXPOSE 8006 VOLUME /storage -ENV CPU_CORES "1" +ENV CPU_CORES "2" ENV RAM_SIZE "4G" ENV DISK_SIZE "64G" diff --git a/src/entry.sh b/src/entry.sh index e8a0594..7a9560a 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -24,6 +24,9 @@ if [[ "${DISPLAY,,}" == "web" ]]; then websockify -D --web /usr/share/novnc/ 8006 localhost:5900 2>/dev/null fi +mkdir -p /tmp/emulated_tpm +swtpm socket -t -d --tpmstate dir=/tmp/emulated_tpm --ctrl type=unixio,path=/tmp/emulated_tpm/swtpm-sock --log level=1 --tpm2 + info "Booting Windows using $VERS..." [[ "$DEBUG" == [Yy1]* ]] && set -x diff --git a/src/install.sh b/src/install.sh index 02ee717..0c5c436 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash set -Eeuo pipefail -: "${VERSION:="win10x64"}" +: "${VERSION:="win11x64"}" + +ARGUMENTS="-chardev socket,id=chrtpm,path=/tmp/emulated_tpm/swtpm-sock $ARGUMENTS" +ARGUMENTS="-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 $ARGUMENTS" BASE="$VERSION.iso" [ -f "$STORAGE/$BASE" ] && return 0 @@ -13,28 +16,30 @@ else PROGRESS="--progress=dot:giga" fi -SCRIPT="$STORAGE/mido.sh" +DEST="$STORAGE/drivers.img" +[ ! -f "$DEST" ] && cp /run/drivers.iso $DEST + +rm -rf "$STORAGE/tmp" +mkdir -p "$STORAGE/tmp" +SCRIPT="$STORAGE/tmp/mido.sh" -rm -f "$SCRIPT" cp /run/mido.sh "$SCRIPT" chmod +x "$SCRIPT" +cd "$STORAGE/tmp" bash "$SCRIPT" "$VERSION" rm -f "$SCRIPT" -[ ! -f "$STORAGE/$BASE" ] && error "Failed to download $VERSION.iso!" && exit 66 +[ ! -f "$STORAGE/tmp/$BASE" ] && error "Failed to download $VERSION.iso from the Microsoft servers!" && exit 66 -DEST="$STORAGE/drivers.img" +info "Modifying ISO to remove keypress requirement during boot..." -if [ ! -f "$DEST" ]; then +7z x "$BASE" -ounpack +genisoimage -b boot/etfsboot.com -no-emul-boot -c BOOT.CAT -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -v -V "Custom" -udf -boot-info-table -eltorito-alt-boot -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin -no-emul-boot -o "$STORAGE/tmp/$BASE.tmp" -allow-limited-size unpack - info "Downloading VirtIO drivers for Windows..." - DRIVERS="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" +mv "$STORAGE/tmp/$BASE.tmp" "$STORAGE/$BASE" +rm -rf "$STORAGE/tmp" - { wget "$DRIVERS" -O "$DEST" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : - - (( rc != 0 )) && info "Failed to download $DRIVERS, reason: $rc" && rm -f "$DEST" - -fi +cd /run return 0