Implement download-iso

This commit is contained in:
Liam 2023-12-21 13:20:00 -06:00 committed by Martin Wimpress
parent fb9298448e
commit c9df8f3b32
1 changed files with 24 additions and 3 deletions

View File

@ -48,6 +48,15 @@ elif [ "${1}" == '--show-iso-url' ] || [ "${1}" == '-s' ]; then
elif [ "${1}" == '--open-distro-homepage' ] || [ "${1}" == '-o' ]; then elif [ "${1}" == '--open-distro-homepage' ] || [ "${1}" == '-o' ]; then
open_distro_homepage="on" open_distro_homepage="on"
set -- "$2" set -- "$2"
elif [ "${1}" == '--download-iso' ] || [ "${1}" == '-d' ]; then
download_iso="on"
if [ -n "$4" ]; then
set -- "$2" "$3" "$4"
elif [ -n "$3" ]; then
set -- "$2" "$3"
else
set -- "$2"
fi
fi fi
function pretty_name() { function pretty_name() {
@ -924,7 +933,11 @@ function check_hash() {
local iso="" local iso=""
local hash="" local hash=""
local hash_algo="" local hash_algo=""
iso="${VM_PATH}/${1}" if [ "${download_iso}" == "on" ]; then
iso="${1}"
else
iso="${VM_PATH}/${1}"
fi
hash="${2}" hash="${2}"
# Guess the hash algorithm by the hash length # Guess the hash algorithm by the hash length
@ -974,9 +987,11 @@ function web_get() {
elif [ "${test_iso_url}" == 'on' ]; then elif [ "${test_iso_url}" == 'on' ]; then
wget --spider "${URL}" wget --spider "${URL}"
exit 0 exit 0
elif [ "${download_iso}" == 'on' ]; then
DIR="$(pwd)"
fi fi
if ! mkdir -p "${DIR}" 2>/dev/null; then if [ "${DIR}" != "$(pwd)" ] && ! mkdir -p "${DIR}" 2>/dev/null; then
echo "ERROR! Unable to create directory ${DIR}" echo "ERROR! Unable to create directory ${DIR}"
exit 1 exit 1
fi fi
@ -1056,6 +1071,10 @@ function make_vm_config() {
local GUEST="" local GUEST=""
local SEC_BOOT="" local SEC_BOOT=""
if [ "${download_iso}" == "on" ]; then
exit 0
fi
IMAGE_FILE="${1}" IMAGE_FILE="${1}"
ISO_FILE="${2}" ISO_FILE="${2}"
case "${OS}" in case "${OS}" in
@ -2979,7 +2998,9 @@ else
Test if ISO is available Test if ISO is available
--test-iso-url / -t {distro} {release} [edition] --test-iso-url / -t {distro} {release} [edition]
Open distro homepage Open distro homepage
--open-distro-homepage / -o {distro}" --open-distro-homepage / -o {distro}
Only download ISO
--download-iso / -d {distro} {release} [edition]"
exit 1 exit 1
fi fi