mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 11:25:49 +00:00
feat: Allow automatic install of custom.iso
This commit is contained in:
parent
1275a654ed
commit
147c415bd4
1 changed files with 97 additions and 59 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
: "${MANUAL:=""}"
|
: "${MANUAL:=""}"
|
||||||
: "${EXTERNAL:=""}"
|
|
||||||
: "${VERSION:="win11x64"}"
|
: "${VERSION:="win11x64"}"
|
||||||
|
|
||||||
[[ "${VERSION,,}" == "11" ]] && VERSION="win11x64"
|
[[ "${VERSION,,}" == "11" ]] && VERSION="win11x64"
|
||||||
|
|
@ -48,12 +47,10 @@ fi
|
||||||
|
|
||||||
MSG="Windows is being started, please wait..."
|
MSG="Windows is being started, please wait..."
|
||||||
|
|
||||||
BASE="custom.iso"
|
|
||||||
if [ ! -f "$STORAGE/$BASE" ]; then
|
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
BASE="$VERSION.iso"
|
BASE="$VERSION.iso"
|
||||||
|
|
||||||
if [ ! -f "$STORAGE/$BASE" ]; then
|
if [ ! -f "$STORAGE/$BASE" ]; then
|
||||||
MSG="Windows is being downloaded, please wait..."
|
MSG="Windows is being downloaded, please wait..."
|
||||||
fi
|
fi
|
||||||
|
|
@ -69,7 +66,8 @@ if [ ! -f "$STORAGE/$BASE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
[[ "${BASE,,}" == "custom."* ]] && BASE="target.iso"
|
||||||
|
|
||||||
html "$MSG"
|
html "$MSG"
|
||||||
|
|
||||||
|
|
@ -82,6 +80,21 @@ mkdir -p "$TMP"
|
||||||
ISO="$TMP/$BASE"
|
ISO="$TMP/$BASE"
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
|
|
||||||
|
CUSTOM="custom.iso"
|
||||||
|
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.img"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="Custom.iso"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="Custom.img"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.ISO"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.IMG"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="CUSTOM.ISO"
|
||||||
|
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="CUSTOM.IMG"
|
||||||
|
|
||||||
|
if [ -f "$STORAGE/$CUSTOM" ]; then
|
||||||
|
ISO="$STORAGE/$CUSTOM"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$ISO" ]; then
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
SCRIPT="$TMP/mido.sh"
|
SCRIPT="$TMP/mido.sh"
|
||||||
|
|
@ -112,14 +125,28 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -f "$ISO" ] && echo && error "Failed to download $VERSION" && exit 61
|
[ ! -f "$ISO" ] && echo && error "Failed to download $VERSION" && exit 61
|
||||||
|
fi
|
||||||
|
|
||||||
SIZE=$(stat -c%s "$ISO")
|
SIZE=$(stat -c%s "$ISO")
|
||||||
|
SIZE_GB=$(( (SIZE + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
if ((SIZE<10000000)); then
|
if ((SIZE<10000000)); then
|
||||||
echo && error "Invalid ISO file: Size is smaller than 10 MB" && exit 62
|
echo && error "Invalid ISO file: Size is smaller than 10 MB" && exit 62
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
|
||||||
|
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
|
if (( SIZE > SPACE )); then
|
||||||
|
error "Not enough free space in $STORAGE, have $SPACE_GB GB available but need at least $SIZE_GB GB." && exit 63
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$CUSTOM" ]; then
|
||||||
|
MSG="Extracting custom ISO image..."
|
||||||
|
else
|
||||||
MSG="Extracting downloaded ISO image..."
|
MSG="Extracting downloaded ISO image..."
|
||||||
|
fi
|
||||||
|
|
||||||
echo && info "$MSG" && html "$MSG"
|
echo && info "$MSG" && html "$MSG"
|
||||||
|
|
||||||
DIR="$TMP/unpack"
|
DIR="$TMP/unpack"
|
||||||
|
|
@ -138,11 +165,13 @@ if [ ! -f "$DIR/$ETFS" ] || [ ! -f "$DIR/$EFISYS" ]; then
|
||||||
else
|
else
|
||||||
warn "failed to locate file 'efisys_noprompt.bin' in ISO image, $FB"
|
warn "failed to locate file 'efisys_noprompt.bin' in ISO image, $FB"
|
||||||
fi
|
fi
|
||||||
mv "$ISO" "$STORAGE/$BASE"
|
mv -f "$ISO" "$STORAGE/$BASE"
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
echo && return 0
|
echo && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -z "$CUSTOM" ] && rm -f "$ISO"
|
||||||
|
|
||||||
if [ -z "$MANUAL" ]; then
|
if [ -z "$MANUAL" ]; then
|
||||||
|
|
||||||
MANUAL="N"
|
MANUAL="N"
|
||||||
|
|
@ -156,11 +185,10 @@ fi
|
||||||
XML=""
|
XML=""
|
||||||
|
|
||||||
if [[ "$MANUAL" != [Yy1]* ]]; then
|
if [[ "$MANUAL" != [Yy1]* ]]; then
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
|
||||||
|
|
||||||
XML="$VERSION.xml"
|
[[ "$EXTERNAL" != [Yy1]* ]] && XML="$VERSION.xml"
|
||||||
|
|
||||||
else
|
if [ ! -f "/run/assets/$XML" ]; then
|
||||||
|
|
||||||
MSG="Detecting Windows version from ISO image..."
|
MSG="Detecting Windows version from ISO image..."
|
||||||
info "$MSG" && html "$MSG"
|
info "$MSG" && html "$MSG"
|
||||||
|
|
@ -190,7 +218,12 @@ if [[ "$MANUAL" != [Yy1]* ]]; then
|
||||||
if [ -n "$DETECTED" ]; then
|
if [ -n "$DETECTED" ]; then
|
||||||
|
|
||||||
XML="$DETECTED.xml"
|
XML="$DETECTED.xml"
|
||||||
echo "Detected image of type '$DETECTED', will apply autounattend.xml file."
|
|
||||||
|
if [ -f "/run/assets/$XML" ]; then
|
||||||
|
echo "Detected image of type '$DETECTED', will apply an autounattend.xml file."
|
||||||
|
else
|
||||||
|
warn "detected image of type '$DETECTED', but no matching .xml file exists, $FB."
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
if [ -z "$NAME" ]; then
|
if [ -z "$NAME" ]; then
|
||||||
|
|
@ -255,25 +288,30 @@ if [ -f "$ASSET" ]; then
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
else
|
|
||||||
if [ -n "$XML" ]; then
|
|
||||||
warn "XML file '$XML' does not exist, $FB" && echo
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CAT="BOOT.CAT"
|
CAT="BOOT.CAT"
|
||||||
LABEL="${BASE%.*}"
|
LABEL="${BASE%.*}"
|
||||||
LABEL="${LABEL::30}"
|
LABEL="${LABEL::30}"
|
||||||
ISO="$TMP/$LABEL.tmp"
|
OUT="$TMP/$LABEL.tmp"
|
||||||
rm -f "$ISO"
|
rm -f "$OUT"
|
||||||
|
|
||||||
|
SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
|
||||||
|
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
|
if (( SIZE > SPACE )); then
|
||||||
|
error "Not enough free space in $STORAGE, have $SPACE_GB GB available but need at least $SIZE_GB GB." && exit 63
|
||||||
|
fi
|
||||||
|
|
||||||
MSG="Generating new ISO image for installation..."
|
MSG="Generating new ISO image for installation..."
|
||||||
info "$MSG" && html "$MSG"
|
info "$MSG" && html "$MSG"
|
||||||
|
|
||||||
genisoimage -b "$ETFS" -no-emul-boot -c "$CAT" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -quiet -V "$LABEL" -udf \
|
genisoimage -b "$ETFS" -no-emul-boot -c "$CAT" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -quiet -V "$LABEL" -udf \
|
||||||
-boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -o "$ISO" -allow-limited-size "$DIR"
|
-boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -o "$OUT" -allow-limited-size "$DIR"
|
||||||
|
|
||||||
|
[ -n "$CUSTOM" ] && rm -f "$ISO"
|
||||||
|
mv "$OUT" "$STORAGE/$BASE"
|
||||||
|
|
||||||
mv "$ISO" "$STORAGE/$BASE"
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
html "Successfully prepared image for installation..."
|
html "Successfully prepared image for installation..."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue