Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,31 @@ downloadFile() {
return 1
}

bootFile() {

local file="$1"
local ext="${file##*.}"
local dest="$STORAGE/boot.$ext"

if [[ "$file" == "$dest" ]]; then
BOOT="$file"
return 0
fi

if [[ "${file,,}" == "/boot.${ext,,}" || "${file,,}" == "/custom.${ext,,}" ]]; then
BOOT="$file"
return 0
fi

if ! mv -f "$file" "$dest"; then
error "Failed to move $file to $dest !"
return 1
fi

BOOT="$dest"
return 0
}

findFile() {

local dir file
Expand All @@ -74,6 +99,8 @@ findFile() {
[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname "$fname" -print -quit)
[ ! -s "$file" ] && return 1

! bootFile "$file" && return 1

return 0
}

Expand All @@ -85,6 +112,7 @@ fi

findFile "boot" "iso" && return 0
findFile "boot" "img" && return 0
findFile "boot" "raw" && return 0
findFile "boot" "qcow2" && return 0

if hasDisk; then
Expand Down Expand Up @@ -114,13 +142,6 @@ if ! downloadFile "$URL" "$base" "$name"; then
rm -f "$STORAGE/$base" && exit 60
fi

ext="${base##*.}"
dest="$STORAGE/boot.$ext"

if ! mv -f "$STORAGE/$base" "$dest"; then
error "Failed to move file to $dest !" && exit 61
fi
! bootFile "$STORAGE/$base" && exit 61

BOOT="$dest"

return 0