Update install.sh

This commit is contained in:
Kroese 2024-01-24 05:20:35 +01:00 committed by GitHub
parent d6091e7e9d
commit ecba1d34ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -199,8 +199,8 @@ startInstall() {
downloadImage() { downloadImage() {
local url="$1" local iso="$1"
local iso="$2" local url="$2"
local progress local progress
rm -f "$iso" rm -f "$iso"
@ -209,7 +209,7 @@ downloadImage() {
cd "$TMP" cd "$TMP"
/run/mido.sh "$url" /run/mido.sh "$url"
cd /run cd /run
[ ! -f "$iso" ] && error "Failed to download $url" && exit 61 [ ! -f "$iso" ] && error "Failed to download $url" && exit 61
return 0 return 0
@ -234,8 +234,13 @@ downloadImage() {
extractImage() { extractImage() {
local dir="$1" local iso="$1"
local iso="$2" local dir="$2"
local msg="Extracting downloaded ISO image..."
[ -n "$CUSTOM" ] && msg="Extracting local ISO image..."
info "$msg" && html "$msg"
local size=$(stat -c%s "$iso") local size=$(stat -c%s "$iso")
local size_gb=$(( (size + 1073741823)/1073741824 )) local size_gb=$(( (size + 1073741823)/1073741824 ))
local space=$(df --output=avail -B 1 "$TMP" | tail -n 1) local space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
@ -249,11 +254,6 @@ extractImage() {
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63 error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63
fi fi
local msg="Extracting downloaded ISO image..."
[ -n "$CUSTOM" ] && msg="Extracting local ISO image..."
info "$msg" && html "$msg"
rm -rf "$dir" rm -rf "$dir"
7z x "$iso" -o"$dir" > /dev/null 7z x "$iso" -o"$dir" > /dev/null
@ -289,7 +289,7 @@ findVersion() {
return 0 return 0
} }
getXML() { selectXML() {
local dir="$1" local dir="$1"
@ -310,7 +310,7 @@ getXML() {
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB"
return 0 return 0
fi fi
local tag="DISPLAYNAME" local tag="DISPLAYNAME"
local result=$(wimlib-imagex info -xml "$loc" | tr -d '\000') local result=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
local name=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result") local name=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result")
@ -366,7 +366,7 @@ updateImage() {
warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
return 0 return 0
fi fi
info "Adding XML file for automatic installation..." info "Adding XML file for automatic installation..."
local index="1" local index="1"
@ -384,14 +384,16 @@ updateImage() {
buildImage() { buildImage() {
local dir="$1" local dir="$1"
local iso="$2"
local cat="BOOT.CAT" local cat="BOOT.CAT"
local label="${BASE%.*}" local label="${BASE%.*}"
label="${label::30}" label="${label::30}"
local out="$TMP/$label.tmp" local out="$TMP/$label.tmp"
rm -f "$out" rm -f "$out"
local size=$(stat -c%s "$iso") local msg="Generating updated ISO image..."
info "$msg" && html "$msg"
local size=$(du -h -b --max-depth=0 "$dir" | cut -f1)
local size_gb=$(( (size + 1073741823)/1073741824 )) local size_gb=$(( (size + 1073741823)/1073741824 ))
local space=$(df --output=avail -B 1 "$TMP" | tail -n 1) local space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
local space_gb=$(( (space + 1073741823)/1073741824 )) local space_gb=$(( (space + 1073741823)/1073741824 ))
@ -400,9 +402,6 @@ buildImage() {
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63 error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63
fi fi
local msg="Generating updated ISO image..."
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 "$out" -allow-limited-size "$dir" -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -o "$out" -allow-limited-size "$dir"
@ -416,9 +415,7 @@ buildImage() {
return 0 return 0
} }
####################### ######################################
# #
#######################
if ! startInstall; then if ! startInstall; then
rm -rf "$TMP" rm -rf "$TMP"
@ -426,10 +423,10 @@ if ! startInstall; then
fi fi
if [ ! -f "$ISO" ]; then if [ ! -f "$ISO" ]; then
downloadImage "$VERSION" "$ISO" downloadImage "$ISO" "$VERSION"
fi fi
if ! extractImage "$DIR" "$ISO"; then if ! extractImage "$ISO" "$DIR"; then
if [[ "$ISO" != "$STORAGE/$BASE" ]]; then if [[ "$ISO" != "$STORAGE/$BASE" ]]; then
mv -f "$ISO" "$STORAGE/$BASE" mv -f "$ISO" "$STORAGE/$BASE"
@ -440,9 +437,12 @@ if ! extractImage "$DIR" "$ISO"; then
fi fi
getXML "$DIR" selectXML "$DIR"
updateImage "$DIR" "/run/assets/$XML" updateImage "$DIR" "/run/assets/$XML"
buildImage "$DIR" "$ISO"
buildImage "$DIR"
finishInstall "$STORAGE/$BASE" finishInstall "$STORAGE/$BASE"
html "Successfully prepared image for installation..." html "Successfully prepared image for installation..."