Update install.sh
This commit is contained in:
parent
98531981fc
commit
4e386a85ce
1 changed files with 13 additions and 5 deletions
|
@ -1,18 +1,26 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
iso () {
|
detect () {
|
||||||
|
local dir=""
|
||||||
local file="$1"
|
local file="$1"
|
||||||
[ ! -f "$file" ] && return 1
|
[ ! -f "$file" ] && return 1
|
||||||
[ ! -s "$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"
|
BOOT="$file"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1)
|
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)
|
[ ! -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
|
if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
|
||||||
hasDisk && return 0
|
hasDisk && return 0
|
||||||
|
@ -20,12 +28,12 @@ if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
base=$(basename "$BOOT")
|
base=$(basename "$BOOT")
|
||||||
iso "$STORAGE/$base" && return 0
|
detect "$STORAGE/$base" && return 0
|
||||||
|
|
||||||
base=$(basename "${BOOT%%\?*}")
|
base=$(basename "${BOOT%%\?*}")
|
||||||
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
|
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
|
||||||
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
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"
|
TMP="$STORAGE/${base%.*}.tmp"
|
||||||
rm -f "$TMP"
|
rm -f "$TMP"
|
||||||
|
@ -61,6 +69,6 @@ if ((size<100000)); then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv -f "$TMP" "$STORAGE/$base"
|
mv -f "$TMP" "$STORAGE/$base"
|
||||||
! iso "$STORAGE/$base" && exit 63
|
! detect "$STORAGE/$base" && exit 63
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue