Update install.sh
This commit is contained in:
parent
022ab30399
commit
42f3c453d6
1 changed files with 145 additions and 16 deletions
161
src/install.sh
161
src/install.sh
|
@ -1,6 +1,115 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
getURL() {
|
||||
local id="${1/ /}"
|
||||
local ret="$2"
|
||||
local url=""
|
||||
local name=""
|
||||
|
||||
case "${id,,}" in
|
||||
"alma" )
|
||||
name="AlmaLinux"
|
||||
url="https://repo.almalinux.org/almalinux/9/live/x86_64/AlmaLinux-9.5-x86_64-Live-GNOME.iso" ;;
|
||||
"alpine" )
|
||||
name="Alpine Linux"
|
||||
url="https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso" ;;
|
||||
"arch" )
|
||||
name="Arch Linux"
|
||||
url="https://geo.mirror.pkgbuild.com/iso/2025.03.01/archlinux-x86_64.iso" ;;
|
||||
"cachy" )
|
||||
name="CachyOS"
|
||||
url="https://cdn77.cachyos.org/ISO/desktop/250202/cachyos-desktop-linux-250202.iso" ;;
|
||||
"centos" )
|
||||
name="CentOS Stream"
|
||||
url="https://mirrors.xtom.de/centos-stream/10-stream/BaseOS/x86_64/iso/CentOS-Stream-10-latest-x86_64-dvd1.iso" ;;
|
||||
"debian" )
|
||||
name="Debian"
|
||||
url="https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-12.9.0-amd64-gnome.iso" ;;
|
||||
"endeavour" )
|
||||
name="EndeavourOS"
|
||||
url="https://mirrors.gigenet.com/endeavouros/iso/EndeavourOS_Mercury-2025.02.08.iso" ;;
|
||||
"fedora" )
|
||||
name="Fedora Linux"
|
||||
url="https://download.fedoraproject.org/pub/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-41-1.4.iso" ;;
|
||||
"gentoo" )
|
||||
name="Gentoo Linux"
|
||||
url="https://distfiles.gentoo.org/releases/amd64/autobuilds/20250309T170330Z/livegui-amd64-20250309T170330Z.iso" ;;
|
||||
"kali" )
|
||||
name="Kali Linux"
|
||||
url="https://cdimage.kali.org/kali-2024.4/kali-linux-2024.4-live-amd64.iso" ;;
|
||||
"kubuntu" )
|
||||
name="Kubuntu"
|
||||
url="https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso" ;;
|
||||
"mint" )
|
||||
name="Linux Mint"
|
||||
url="https://mirrors.layeronline.com/linuxmint/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso" ;;
|
||||
"manjaro" )
|
||||
name="Manjaro"
|
||||
url="https://download.manjaro.org/kde/24.2.1/manjaro-kde-24.2.1-241216-linux612.iso" ;;
|
||||
"mx" )
|
||||
name="MX Linux"
|
||||
url="https://mirror.umd.edu/mxlinux-iso/MX/Final/Xfce/MX-23.5_x64.iso" ;;
|
||||
"netbsd" )
|
||||
name="NetBSD"
|
||||
url="https://cdn.netbsd.org/pub/NetBSD/NetBSD-10.1/images/NetBSD-10.1-amd64.iso" ;;
|
||||
"nixos" )
|
||||
name="NixOS"
|
||||
url="https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-x86_64-linux.iso" ;;
|
||||
"opensuse" )
|
||||
name="OpenSUSE"
|
||||
url="https://download.opensuse.org/distribution/leap/15.0/live/openSUSE-Leap-15.0-GNOME-Live-x86_64-Current.iso" ;;
|
||||
"oracle" )
|
||||
name="Oracle Linux"
|
||||
url="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/x86_64/OracleLinux-R9-U5-x86_64-boot.iso" ;;
|
||||
"rocky" )
|
||||
name="Rocky Linux"
|
||||
url="https://dl.rockylinux.org/pub/rocky/9/live/x86_64/Rocky-9-Workstation-x86_64-latest.iso" ;;
|
||||
"slack" )
|
||||
name="Slackware"
|
||||
url="https://slackware.nl/slackware-live/slackware64-15.0-live/slackware64-live-15.0.iso" ;;
|
||||
"tails" )
|
||||
name="Tails"
|
||||
url="https://download.tails.net/tails/stable/tails-amd64-6.13/tails-amd64-6.13.img" ;;
|
||||
"ubuntu" )
|
||||
name="Ubuntu Desktop"
|
||||
url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-desktop-amd64.iso" ;;
|
||||
"ubuntus" )
|
||||
name="Ubuntu Server"
|
||||
url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso" ;;
|
||||
"xubuntu" )
|
||||
name="Xubuntu"
|
||||
url="https://mirror.us.leaseweb.net/ubuntu-cdimage/xubuntu/releases/24.04/release/xubuntu-24.04.2-desktop-amd64.iso" ;;
|
||||
esac
|
||||
|
||||
case "${ret,,}" in
|
||||
"name" ) echo "$name" ;;
|
||||
*) echo "$url";;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
moveFile() {
|
||||
|
||||
local file="$1"
|
||||
local ext="${file##*.}"
|
||||
local dest="$STORAGE/boot.$ext"
|
||||
|
||||
if [[ "$file" == "$dest" ]] || [[ "$file" == "/boot.$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
|
||||
}
|
||||
|
||||
detectType() {
|
||||
|
||||
local dir=""
|
||||
|
@ -10,25 +119,26 @@ detectType() {
|
|||
[ ! -s "$file" ] && return 1
|
||||
|
||||
case "${file,,}" in
|
||||
*".iso" | *".img" | *".raw" | *".qcow2" )
|
||||
BOOT="$file" ;;
|
||||
*".iso" | *".img" | *".raw" | *".qcow2" ) ;;
|
||||
* ) return 1 ;;
|
||||
esac
|
||||
|
||||
[ -n "$BOOT_MODE" ] && return 0
|
||||
[[ "${file,,}" != *".iso" ]] && return 0
|
||||
if [ -n "$BOOT_MODE" ] || [[ "${file,,}" != *".iso" ]]; then
|
||||
! moveFile "$file" && return 1
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Automaticly detect UEFI-compatible ISO's
|
||||
dir=$(isoinfo -f -i "$file")
|
||||
|
||||
if [ -z "$dir" ]; then
|
||||
BOOT=""
|
||||
error "Failed to read ISO file, invalid format!" && return 1
|
||||
if [ -n "$dir" ]; then
|
||||
dir=$(echo "${dir^^}" | grep "^/EFI")
|
||||
[ -z "$dir" ] && BOOT_MODE="legacy"
|
||||
else
|
||||
error "Failed to read ISO file, invalid format!"
|
||||
fi
|
||||
|
||||
dir=$(echo "${dir^^}" | grep "^/EFI")
|
||||
[ -z "$dir" ] && BOOT_MODE="legacy"
|
||||
|
||||
! moveFile "$file" && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -36,7 +146,8 @@ downloadFile() {
|
|||
|
||||
local url="$1"
|
||||
local base="$2"
|
||||
local msg rc total total_mb progress
|
||||
local name="$3"
|
||||
local msg rc total total_mb progress name
|
||||
|
||||
local dest="$STORAGE/$base.tmp"
|
||||
rm -f "$dest"
|
||||
|
@ -48,8 +159,14 @@ downloadFile() {
|
|||
progress="--progress=dot:giga"
|
||||
fi
|
||||
|
||||
msg="Downloading image"
|
||||
info "Downloading $base..."
|
||||
if [ -z "$name" ]; then
|
||||
name="$base"
|
||||
msg="Downloading image"
|
||||
else
|
||||
msg="Downloading $name"
|
||||
fi
|
||||
|
||||
info "Downloading $name..."
|
||||
html "$msg..."
|
||||
|
||||
/run/progress.sh "$dest" "0" "$msg ([P])..." &
|
||||
|
@ -189,7 +306,19 @@ findFile "qcow2" && 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 a disk image file." && exit 64
|
||||
error "No value specified for the BOOT variable." && exit 64
|
||||
fi
|
||||
|
||||
url=$(getURL "$BOOT" "url")
|
||||
name=$(getURL "$BOOT" "name")
|
||||
[ -n "$url" ] && BOOT="$url"
|
||||
|
||||
if [[ "$BOOT" != *"."* ]]; then
|
||||
error "Invalid BOOT value specified, shortcut \"$BOOT\" is not recognized!" && exit 64
|
||||
fi
|
||||
|
||||
if [[ "${BOOT,,}" != "http"* ]]; then
|
||||
error "Invalid BOOT value specified, \"$BOOT\" is not a valid URL!" && exit 64
|
||||
fi
|
||||
|
||||
base=$(basename "${BOOT%%\?*}")
|
||||
|
@ -227,7 +356,7 @@ case "${base,,}" in
|
|||
* ) error "Unknown file extension, type \".${base/*./}\" is not recognized!" && exit 33 ;;
|
||||
esac
|
||||
|
||||
if ! downloadFile "$BOOT" "$base"; then
|
||||
if ! downloadFile "$BOOT" "$base" "$name"; then
|
||||
rm -f "$STORAGE/$base.tmp" && exit 60
|
||||
fi
|
||||
|
||||
|
@ -298,4 +427,4 @@ dst="$STORAGE/${base%.*}.$target_ext"
|
|||
|
||||
base=$(basename "$dst")
|
||||
detectType "$STORAGE/$base" && return 0
|
||||
error "Cannot read file \"${base}\"" && exit 36
|
||||
error "Cannot convert file \"${base}\"" && exit 36
|
||||
|
|
Loading…
Reference in a new issue