Update install.sh
This commit is contained in:
parent
359936cfb2
commit
b40832c08e
1 changed files with 14 additions and 18 deletions
|
@ -1,36 +1,31 @@
|
|||
#!/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)
|
||||
iso () {
|
||||
local file="$1"
|
||||
[ ! -f "$file" ] && return 1
|
||||
[ ! -s "$file" ] && return 1
|
||||
|
||||
if [ -f "$file" ] && [ -s "$file" ]; then
|
||||
BOOT="$file"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "$BOOT" ]; then
|
||||
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
|
||||
|
||||
if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; 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
|
||||
iso "$STORAGE/$base" && return 0
|
||||
|
||||
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
|
||||
iso "$STORAGE/$base" && return 0
|
||||
|
||||
TMP="$STORAGE/${base%.*}.tmp"
|
||||
rm -f "$TMP"
|
||||
|
@ -62,6 +57,7 @@ if ((size<100000)); then
|
|||
error "Invalid ISO file: Size is smaller than 100 KB" && exit 62
|
||||
fi
|
||||
|
||||
mv -f "$TMP" "$file"
|
||||
mv -f "$TMP" "$STORAGE/$base"
|
||||
! iso "$STORAGE/$base" && exit 63
|
||||
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue