Update install.sh
This commit is contained in:
parent
a6cecf44f9
commit
47ac11a705
1 changed files with 40 additions and 26 deletions
|
|
@ -1,6 +1,45 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
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
|
# Check if running with interactive TTY or redirected to docker log
|
||||||
if [ -t 1 ]; then
|
if [ -t 1 ]; then
|
||||||
progress="--progress=bar:noscroll"
|
progress="--progress=bar:noscroll"
|
||||||
|
|
@ -8,36 +47,11 @@ else
|
||||||
progress="--progress=dot:giga"
|
progress="--progress=dot:giga"
|
||||||
fi
|
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..."
|
msg="Downloading $base..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
/run/progress.sh "$TMP" "" "Downloading $base ([P])..." &
|
/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"
|
fKill "progress.sh"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue