2024-01-14 15:39:24 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-01-14 14:19:58 +00:00
|
|
|
set -Eeuo pipefail
|
|
|
|
|
2024-01-15 22:45:35 +00:00
|
|
|
: "${ATTENDED:="N"}"
|
2024-01-14 19:32:24 +00:00
|
|
|
: "${VERSION:="win11x64"}"
|
|
|
|
|
2024-01-16 18:58:55 +00:00
|
|
|
# Display wait message
|
|
|
|
MSG="Please wait while Windows is being downloaded..."
|
|
|
|
/run/server.sh "Windows" "$MSG" &
|
|
|
|
|
|
|
|
ARGUMENTS="-chardev socket,id=chrtpm,path=/dev/shm/emulated_tpm/swtpm-sock $ARGUMENTS"
|
2024-01-14 19:32:24 +00:00
|
|
|
ARGUMENTS="-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 $ARGUMENTS"
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-14 15:35:58 +00:00
|
|
|
BASE="$VERSION.iso"
|
|
|
|
[ -f "$STORAGE/$BASE" ] && return 0
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
TMP="$STORAGE/tmp"
|
|
|
|
rm -rf "$TMP"
|
|
|
|
mkdir -p "$TMP"
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
if [ -f "$STORAGE/custom.iso" ]; then
|
2024-01-16 01:49:50 +00:00
|
|
|
ATTENDED="Y"
|
|
|
|
LABEL="Custom"
|
2024-01-15 14:15:12 +00:00
|
|
|
cp "$STORAGE/custom.iso" "$TMP/$BASE"
|
|
|
|
fi
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
if [ ! -f "$TMP/$BASE" ]; then
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-16 01:49:50 +00:00
|
|
|
LABEL="$VERSION"
|
2024-01-15 14:15:12 +00:00
|
|
|
SCRIPT="$TMP/mido.sh"
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00: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 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-15 22:45:35 +00:00
|
|
|
info "Preparing ISO image for installation..."
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
DIR="$TMP/unpack"
|
|
|
|
7z x "$TMP/$BASE" -o"$DIR"
|
2024-01-15 22:45:35 +00:00
|
|
|
|
|
|
|
if [[ "$ATTENDED" != [Yy1]* ]]; then
|
|
|
|
if [ -f "/run/assets/$VERSION.xml" ]; then
|
|
|
|
|
|
|
|
wimlib-imagex update "$DIR/sources/boot.wim" 2 \
|
|
|
|
--command "add /run/assets/$VERSION.xml /autounattend.xml"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
genisoimage -b boot/etfsboot.com -no-emul-boot -c BOOT.CAT -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames \
|
2024-01-16 01:49:50 +00:00
|
|
|
-v -V "$LABEL" -udf -boot-info-table -eltorito-alt-boot -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin \
|
2024-01-15 22:45:35 +00:00
|
|
|
-no-emul-boot -o "$TMP/$BASE.tmp" -allow-limited-size "$DIR"
|
2024-01-14 14:19:58 +00:00
|
|
|
|
2024-01-15 14:15:12 +00:00
|
|
|
mv "$TMP/$BASE.tmp" "$STORAGE/$BASE"
|
|
|
|
rm -rf "$TMP"
|
2024-01-14 14:19:58 +00:00
|
|
|
|
|
|
|
return 0
|