From 4e386a85ce0890b2aa4bb24072dc35e9d8c610e6 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 12 Jun 2024 02:00:26 +0200 Subject: [PATCH] Update install.sh --- src/install.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/install.sh b/src/install.sh index f56d437..57d3d67 100644 --- a/src/install.sh +++ b/src/install.sh @@ -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