Update install.sh

This commit is contained in:
Kroese 2024-05-22 12:17:33 +02:00 committed by GitHub
parent a6cecf44f9
commit 47ac11a705
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,45 @@
#!/usr/bin/env bash
set -Eeuo pipefail
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)
if [ ! -s "$file" ] && [[ "${BOOT,,}" != "http"* ]]; then
base=$(basename "$BOOT")
file="$STORAGE/$base"
fi
if [ -f "$file" ] && [ -s "$file" ]; then
BOOT="$file"
return 0
fi
if [ -z "$BOOT" ]; then
hasDisk && return 0
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
fi
base=$(basename "$BOOT")
file="$STORAGE/$base"
if [ -f "$file" ] && [ -s "$file" ]; then
BOOT="$file"
return 0
fi
base=$(basename "${BOOT%%\?*}")
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
file="$STORAGE/$base"
if [ -f "$file" ] && [ -s "$file" ]; then
BOOT="$file"
return 0
fi
TMP="$STORAGE/${base%.*}.tmp"
rm -f "$TMP"
# Check if running with interactive TTY or redirected to docker log
if [ -t 1 ]; then
progress="--progress=bar:noscroll"
@ -8,36 +47,11 @@ else
progress="--progress=dot:giga"
fi
file="/boot.iso" && [ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0
file="/boot.img" && [ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0
file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso -printf "%f\n" | head -n 1)
[ -z "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.img -printf "%f\n" | head -n 1)
[ -n "$file" ] && file="$STORAGE/$file"
[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0
if [ -z "$BOOT" ]; then
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
fi
base=$(basename "$BOOT")
[ -n "$base" ] && file="$STORAGE/$base"
[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0
base=$(basename "${BOOT%%\?*}")
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
[ -n "$base" ] && file="$STORAGE/$base"
[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0
TMP="$STORAGE/${base%.*}.tmp"
rm -f "$TMP"
msg="Downloading $base..."
info "$msg" && html "$msg"
/run/progress.sh "$TMP" "" "Downloading $base ([P])..." &
{ wget "$BOOT" -O "$TMP" -q --timeout=10 --show-progress "$progress"; rc=$?; } || :
{ wget "$BOOT" -O "$TMP" -q --timeout=30 --show-progress "$progress"; rc=$?; } || :
fKill "progress.sh"