install.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. set -Eeuo pipefail
  3. : "${VERSION:="win11x64"}"
  4. ARGUMENTS="-chardev socket,id=chrtpm,path=/tmp/emulated_tpm/swtpm-sock $ARGUMENTS"
  5. ARGUMENTS="-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 $ARGUMENTS"
  6. BASE="$VERSION.iso"
  7. [ -f "$STORAGE/$BASE" ] && return 0
  8. TMP="$STORAGE/tmp"
  9. rm -rf "$TMP"
  10. mkdir -p "$TMP"
  11. if [ -f "$STORAGE/custom.iso" ]; then
  12. cp "$STORAGE/custom.iso" "$TMP/$BASE"
  13. fi
  14. if [ ! -f "$TMP/$BASE" ]; then
  15. SCRIPT="$TMP/mido.sh"
  16. cp /run/mido.sh "$SCRIPT"
  17. chmod +x "$SCRIPT"
  18. cd "$TMP"
  19. bash "$SCRIPT" "$VERSION"
  20. cd /run
  21. rm -f "$SCRIPT"
  22. [ ! -f "$TMP/$BASE" ] && error "Failed to download $VERSION.iso from the Microsoft servers!" && exit 66
  23. fi
  24. info "Customizing ISO to remove keypress requirement during boot..."
  25. DIR="$TMP/unpack"
  26. 7z x "$TMP/$BASE" -o"$DIR"
  27. 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"
  28. mv "$TMP/$BASE.tmp" "$STORAGE/$BASE"
  29. rm -rf "$TMP"
  30. return 0