Update install.sh

This commit is contained in:
Kroese 2024-06-12 02:00:26 +02:00 committed by GitHub
parent 98531981fc
commit 4e386a85ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,18 +1,26 @@
#!/usr/bin/env bash
set -Eeuo pipefail
iso () {
detect () {
local dir=""
local file="$1"
[ ! -f "$file" ] && return 1
[ ! -s "$file" ] && return 1
dir=$(isoinfo -f -i "$file")
# Automaticly detect UEFI-compatible ISO's
if echo "${dir^^}" | grep -q "^/EFI"; then
[ -z "${BOOT_MODE:-}" ] && BOOT_MODE="uefi"
fi
BOOT="$file"
return 0
}
file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1)
[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1)
iso "$file" && return 0
detect "$file" && return 0
if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
hasDisk && return 0
@ -20,12 +28,12 @@ if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
fi
base=$(basename "$BOOT")
iso "$STORAGE/$base" && return 0
detect "$STORAGE/$base" && return 0
base=$(basename "${BOOT%%\?*}")
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
iso "$STORAGE/$base" && return 0
detect "$STORAGE/$base" && return 0
TMP="$STORAGE/${base%.*}.tmp"
rm -f "$TMP"
@ -61,6 +69,6 @@ if ((size<100000)); then
fi
mv -f "$TMP" "$STORAGE/$base"
! iso "$STORAGE/$base" && exit 63
! detect "$STORAGE/$base" && exit 63
return 0