mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 19:35:49 +00:00
feat: Download custom ISO
This commit is contained in:
parent
3c066244ae
commit
b4ca5550c7
1 changed files with 85 additions and 31 deletions
116
src/install.sh
116
src/install.sh
|
|
@ -1,41 +1,70 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
: "${EXTERNAL:="N"}"
|
||||||
: "${ATTENDED:="N"}"
|
: "${ATTENDED:="N"}"
|
||||||
: "${VERSION:="win11x64"}"
|
: "${VERSION:="win11x64"}"
|
||||||
|
|
||||||
# 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"
|
ARGUMENTS="-chardev socket,id=chrtpm,path=/dev/shm/emulated_tpm/swtpm-sock $ARGUMENTS"
|
||||||
ARGUMENTS="-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 $ARGUMENTS"
|
ARGUMENTS="-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 $ARGUMENTS"
|
||||||
|
|
||||||
BASE="$VERSION.iso"
|
[[ "${VERSION,,}" == "http"* ]] && EXTERNAL="Y"
|
||||||
|
MSG="Please wait while Windows is being started..."
|
||||||
|
|
||||||
|
if [ ! -f "$STORAGE/custom.iso" ]; then
|
||||||
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
|
if [ ! -f "$STORAGE/$VERSION.iso" ]; then
|
||||||
|
MSG="Please wait while Windows is being downloaded..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BASE=$(basename "$VERSION")
|
||||||
|
if [ ! -f "$STORAGE/$BASE" ]; then
|
||||||
|
MSG="Please wait while '$BASE' is being downloaded..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Display wait message
|
||||||
|
/run/server.sh "Windows" "$MSG" &
|
||||||
|
|
||||||
|
BASE="custom.iso"
|
||||||
[ -f "$STORAGE/$BASE" ] && return 0
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
|
|
||||||
#if [ -f "$STORAGE/data.qcow2" ]; then
|
BASE="Custom.iso"
|
||||||
# error "Cannot download ISO '$VERSION' while there is an existing hard disk file present (data.qcow2)."
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
# error "If you are sure that the disk contains nothing important, delete it manually and restart the container."
|
|
||||||
# exit 68
|
BASE="custom.ISO"
|
||||||
#fi
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
|
|
||||||
|
BASE="CUSTOM.iso"
|
||||||
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
|
|
||||||
|
BASE="CUSTOM.ISO"
|
||||||
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
|
|
||||||
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
|
BASE="$VERSION.iso"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BASE=$(basename "$VERSION")
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -f "$STORAGE/$BASE" ] && return 0
|
||||||
|
|
||||||
TMP="$STORAGE/tmp"
|
TMP="$STORAGE/tmp"
|
||||||
rm -rf "$TMP" && mkdir -p "$TMP"
|
rm -rf "$TMP" && mkdir -p "$TMP"
|
||||||
|
|
||||||
if [ -f "$STORAGE/custom.iso" ]; then
|
ISO="$TMP/$BASE"
|
||||||
|
rm -f "$ISO"
|
||||||
|
|
||||||
ATTENDED="Y"
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
LABEL="Custom"
|
|
||||||
cp "$STORAGE/custom.iso" "$TMP/$BASE"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
LABEL="$VERSION"
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$TMP/$BASE" ]; then
|
|
||||||
|
|
||||||
SCRIPT="$TMP/mido.sh"
|
SCRIPT="$TMP/mido.sh"
|
||||||
|
|
||||||
|
|
@ -47,8 +76,29 @@ if [ ! -f "$TMP/$BASE" ]; then
|
||||||
rm -f "$SCRIPT"
|
rm -f "$SCRIPT"
|
||||||
cd /run
|
cd /run
|
||||||
|
|
||||||
[ ! -f "$TMP/$BASE" ] && error "Failed to download '$VERSION' from the Microsoft servers!" && exit 66
|
else
|
||||||
|
|
||||||
|
info "Downloading $BASE as boot image..."
|
||||||
|
|
||||||
|
# Check if running with interactive TTY or redirected to docker log
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
PROGRESS="--progress=bar:noscroll"
|
||||||
|
else
|
||||||
|
PROGRESS="--progress=dot:giga"
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ wget "$VERSION" -O "$ISO" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
|
||||||
|
|
||||||
|
(( rc != 0 )) && error "Failed to download $VERSION, reason: $rc" && exit 60
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ ! -f "$ISO" ] && error "Failed to download $VERSION" && exit 61
|
||||||
|
|
||||||
|
SIZE=$(stat -c%s "$ISO")
|
||||||
|
|
||||||
|
if ((SIZE<10000000)); then
|
||||||
|
error "Invalid ISO file: Size is smaller than 10 MB" && exit 62
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Preparing ISO image for installation..."
|
info "Preparing ISO image for installation..."
|
||||||
|
|
@ -56,25 +106,29 @@ info "Preparing ISO image for installation..."
|
||||||
DIR="$TMP/unpack"
|
DIR="$TMP/unpack"
|
||||||
rm -rf "$DIR"
|
rm -rf "$DIR"
|
||||||
|
|
||||||
7z x "$TMP/$BASE" -o"$DIR"
|
7z x "$ISO" -o"$DIR"
|
||||||
|
|
||||||
if [[ "$ATTENDED" != [Yy1]* ]]; then
|
if [[ "$ATTENDED" != [Yy1]* ]]; then
|
||||||
if [ -f "/run/assets/$VERSION.xml" ]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
if [ -f "/run/assets/$VERSION.xml" ]; then
|
||||||
|
|
||||||
wimlib-imagex update "$DIR/sources/boot.wim" 2 \
|
wimlib-imagex update "$DIR/sources/boot.wim" 2 \
|
||||||
--command "add /run/assets/$VERSION.xml /autounattend.xml"
|
--command "add /run/assets/$VERSION.xml /autounattend.xml"
|
||||||
|
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OUT="$TMP/$VERSION.tmp"
|
LABEL="${BASE%.*}"
|
||||||
rm -f "$OUT"
|
ISO="$TMP/$LABEL.tmp"
|
||||||
|
rm -f "$ISO"
|
||||||
|
|
||||||
genisoimage -b boot/etfsboot.com -no-emul-boot -c BOOT.CAT -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames \
|
genisoimage -b boot/etfsboot.com -no-emul-boot -c BOOT.CAT -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames \
|
||||||
-v -V "$LABEL" -udf -boot-info-table -eltorito-alt-boot -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin \
|
-v -V "$LABEL" -udf -boot-info-table -eltorito-alt-boot -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin \
|
||||||
-no-emul-boot -o "$OUT" -allow-limited-size "$DIR"
|
-no-emul-boot -o "$ISO" -allow-limited-size "$DIR"
|
||||||
|
|
||||||
|
mv "$ISO" "$STORAGE/$BASE"
|
||||||
|
|
||||||
mv "$OUT" "$STORAGE/$BASE"
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue