windows-docker/src/install.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

2024-01-14 16:39:24 +01:00
#!/usr/bin/env bash
2024-01-14 15:19:58 +01:00
set -Eeuo pipefail
2024-01-14 20:32:24 +01:00
: "${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"
2024-01-14 15:19:58 +01:00
2024-01-14 16:35:58 +01:00
BASE="$VERSION.iso"
[ -f "$STORAGE/$BASE" ] && return 0
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
TMP="$STORAGE/tmp"
rm -rf "$TMP"
mkdir -p "$TMP"
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
if [ -f "$STORAGE/custom.iso" ]; then
cp "$STORAGE/custom.iso" "$TMP/$BASE"
fi
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
if [ ! -f "$TMP/$BASE" ]; then
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
SCRIPT="$TMP/mido.sh"
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
cp /run/mido.sh "$SCRIPT"
chmod +x "$SCRIPT"
cd "$TMP"
bash "$SCRIPT" "$VERSION"
cd /run
rm -f "$SCRIPT"
[ ! -f "$TMP/$BASE" ] && error "Failed to download $VERSION.iso from the Microsoft servers!" && exit 66
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
fi
info "Customizing ISO to remove keypress requirement during boot..."
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
DIR="$TMP/unpack"
7z x "$TMP/$BASE" -o"$DIR"
genisoimage -b boot/etfsboot.com -no-emul-boot -c BOOT.CAT -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -v -V "$VERSION" -udf -boot-info-table -eltorito-alt-boot -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin -no-emul-boot -o "$TMP/$BASE.tmp" -allow-limited-size "$DIR"
2024-01-14 15:19:58 +01:00
2024-01-15 15:15:12 +01:00
mv "$TMP/$BASE.tmp" "$STORAGE/$BASE"
rm -rf "$TMP"
2024-01-14 15:19:58 +01:00
return 0