mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Refactor get_*() functions to use validate_release()
This commit is contained in:
		
							parent
							
								
									1b9eb20ba6
								
							
						
					
					
						commit
						f34434e4ad
					
				
					 1 changed files with 11 additions and 74 deletions
				
			
		
							
								
								
									
										85
									
								
								quickget
									
										
									
									
									
								
							
							
						
						
									
										85
									
								
								quickget
									
										
									
									
									
								
							|  | @ -488,16 +488,9 @@ function start_vm_info() { | ||||||
| 
 | 
 | ||||||
| function get_elementary() { | function get_elementary() { | ||||||
|     local ISO="" |     local ISO="" | ||||||
|     local RELEASES="" |  | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_elementary) |     validate_release "releases_elementary" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! elementary OS ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     ISO="elementaryos-${RELEASE}-stable.20211005.iso" |     ISO="elementaryos-${RELEASE}-stable.20211005.iso" | ||||||
|     URL="https://ams3.dl.elementary.io/download/MTYzNDU5MDA5NA==/${ISO}" |     URL="https://ams3.dl.elementary.io/download/MTYzNDU5MDA5NA==/${ISO}" | ||||||
|     make_vm_dir |     make_vm_dir | ||||||
|  | @ -508,19 +501,11 @@ function get_elementary() { | ||||||
| 
 | 
 | ||||||
| function get_freebsd() { | function get_freebsd() { | ||||||
|     local ISO="" |     local ISO="" | ||||||
|     local RELEASES="" |  | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_freebsd) |     validate_release "releases_freebsd" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! FreeBSD ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     ISO="FreeBSD-${RELEASE}-RELEASE-amd64-dvd1.iso" |     ISO="FreeBSD-${RELEASE}-RELEASE-amd64-dvd1.iso" | ||||||
|     URL="https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/${RELEASE}/${ISO}" |     URL="https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/${RELEASE}/${ISO}" | ||||||
| 
 |  | ||||||
|     make_vm_dir |     make_vm_dir | ||||||
|     web_get "${URL}" "${VM_PATH}" |     web_get "${URL}" "${VM_PATH}" | ||||||
|     make_vm_config "${ISO}" |     make_vm_config "${ISO}" | ||||||
|  | @ -534,14 +519,8 @@ function get_fedora() { | ||||||
|     local URL="" |     local URL="" | ||||||
|     local SHA256SUM="" |     local SHA256SUM="" | ||||||
|     local VERSION_NUM="" |     local VERSION_NUM="" | ||||||
|     local RELEASES="" |  | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_fedora) |     validate_release "releases_fedora" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! Fedora ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     FEDORA_VERSIONS=$(wget -q -O- "https://getfedora.org/releases.json" | jq '.[] | select((.variant=="Workstation" or .variant=="Spins") and .arch=="x86_64")') |     FEDORA_VERSIONS=$(wget -q -O- "https://getfedora.org/releases.json" | jq '.[] | select((.variant=="Workstation" or .variant=="Spins") and .arch=="x86_64")') | ||||||
|     if [[ "${RELEASE}" == *"beta"* ]]; then |     if [[ "${RELEASE}" == *"beta"* ]]; then | ||||||
|  | @ -576,20 +555,12 @@ function get_fedora() { | ||||||
| function get_linuxmint() { | function get_linuxmint() { | ||||||
|     local FLAVOR="" |     local FLAVOR="" | ||||||
|     local ISO="" |     local ISO="" | ||||||
|     local RELEASES="" |  | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_linuxmint) |     validate_release "releases_linuxmint" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! Linux Mint ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     FLAVOR=$(echo "${OS}" | cut -d'-' -f2) |     FLAVOR=$(echo "${OS}" | cut -d'-' -f2) | ||||||
|     ISO="linuxmint-${RELEASE}-${FLAVOR}-64bit.iso" |     ISO="linuxmint-${RELEASE}-${FLAVOR}-64bit.iso" | ||||||
|     URL="https://mirrors.edge.kernel.org/linuxmint/stable/${RELEASE}/${ISO}" |     URL="https://mirrors.edge.kernel.org/linuxmint/stable/${RELEASE}/${ISO}" | ||||||
| 
 |  | ||||||
|     make_vm_dir |     make_vm_dir | ||||||
|     web_get "${URL}" "${VM_PATH}" |     web_get "${URL}" "${VM_PATH}" | ||||||
|     make_vm_config "${ISO}" |     make_vm_config "${ISO}" | ||||||
|  | @ -601,13 +572,7 @@ function get_opensuse() { | ||||||
|     local RELEASES="" |     local RELEASES="" | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_opensuse) |     validate_release "releases_opensuse" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! openSUSE ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     if [ "${RELEASE}" == "tumbleweed" ]; then |     if [ "${RELEASE}" == "tumbleweed" ]; then | ||||||
|         ISO="openSUSE-Tumbleweed-DVD-x86_64-Current.iso" |         ISO="openSUSE-Tumbleweed-DVD-x86_64-Current.iso" | ||||||
|         URL="https://download.opensuse.org/tumbleweed/iso/${ISO}" |         URL="https://download.opensuse.org/tumbleweed/iso/${ISO}" | ||||||
|  | @ -693,16 +658,9 @@ function get_macos() { | ||||||
| 
 | 
 | ||||||
| function get_popos() { | function get_popos() { | ||||||
|     local ISO="" |     local ISO="" | ||||||
|     local RELEASES="" |  | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_popos) |     validate_release "releases_popos" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! Pop!_OS ${RELEASE} is not a supported release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     ISO="pop-os_${RELEASE}_amd64_intel_9.iso" |     ISO="pop-os_${RELEASE}_amd64_intel_9.iso" | ||||||
|     URL="https://pop-iso.sfo2.cdn.digitaloceanspaces.com/${RELEASE}/amd64/intel/9/${ISO}" |     URL="https://pop-iso.sfo2.cdn.digitaloceanspaces.com/${RELEASE}/amd64/intel/9/${ISO}" | ||||||
|     make_vm_dir |     make_vm_dir | ||||||
|  | @ -715,7 +673,6 @@ function get_ubuntu() { | ||||||
|     local DEVEL="daily-live" |     local DEVEL="daily-live" | ||||||
|     local ISO="" |     local ISO="" | ||||||
|     local PROJECT="" |     local PROJECT="" | ||||||
|     local RELEASES="" |  | ||||||
|     local URL="" |     local URL="" | ||||||
| 
 | 
 | ||||||
|     case ${OS} in |     case ${OS} in | ||||||
|  | @ -726,11 +683,11 @@ function get_ubuntu() { | ||||||
|       ubuntu-studio) |       ubuntu-studio) | ||||||
|         PROJECT="ubuntustudio" |         PROJECT="ubuntustudio" | ||||||
|         DEVEL="dvd";; |         DEVEL="dvd";; | ||||||
|       *) |       *) echo "ERROR! ${OS} is not a recognised Ubuntu flavour." | ||||||
|         echo "ERROR! ${OS} is not a recognised Ubuntu flavour." |          exit 1;; | ||||||
|         exit 1;; |  | ||||||
|     esac |     esac | ||||||
| 
 | 
 | ||||||
|  |     validate_release "releases_ubuntu" | ||||||
|     if [ "${RELEASE}" == "devel" ]; then |     if [ "${RELEASE}" == "devel" ]; then | ||||||
|         URL="http://cdimage.ubuntu.com/${PROJECT}/${DEVEL}/current" |         URL="http://cdimage.ubuntu.com/${PROJECT}/${DEVEL}/current" | ||||||
|     elif [ "${PROJECT}" == "ubuntu" ]; then |     elif [ "${PROJECT}" == "ubuntu" ]; then | ||||||
|  | @ -739,21 +696,10 @@ function get_ubuntu() { | ||||||
|         URL="http://cdimage.ubuntu.com/${PROJECT}/releases/${RELEASE}/release" |         URL="http://cdimage.ubuntu.com/${PROJECT}/releases/${RELEASE}/release" | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_ubuntu) |  | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! ${RELEASE} is not a supported Ubuntu release." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     make_vm_dir |     make_vm_dir | ||||||
| 
 | 
 | ||||||
|     echo "Downloading SHA256SUMS..." |  | ||||||
|     web_get "${URL}/SHA256SUMS" "${VM_PATH}" |     web_get "${URL}/SHA256SUMS" "${VM_PATH}" | ||||||
| 
 |  | ||||||
|     ISO=$(grep 'desktop\|dvd' "${VM_PATH}/SHA256SUMS" | grep amd64 | cut -d' ' -f2 | sed 's|*||g') |     ISO=$(grep 'desktop\|dvd' "${VM_PATH}/SHA256SUMS" | grep amd64 | cut -d' ' -f2 | sed 's|*||g') | ||||||
| 
 |  | ||||||
|     echo "Downloading "${URL}/${ISO}"..." |  | ||||||
|     if [ "${RELEASE}" == "devel" ]; then |     if [ "${RELEASE}" == "devel" ]; then | ||||||
|         zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-${RELEASE}.iso" |         zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-${RELEASE}.iso" | ||||||
|         make_vm_config "${OS}-${RELEASE}.iso" |         make_vm_config "${OS}-${RELEASE}.iso" | ||||||
|  | @ -770,7 +716,6 @@ function get_ubuntu() { | ||||||
|         cd .. |         cd .. | ||||||
|         make_vm_config "${ISO}" |         make_vm_config "${ISO}" | ||||||
|     fi |     fi | ||||||
| 
 |  | ||||||
|     start_vm_info |     start_vm_info | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -788,14 +733,8 @@ function get_windows() { | ||||||
|     local DOWNLOAD_INFO="" |     local DOWNLOAD_INFO="" | ||||||
|     local DOWNLOAD_ID="" |     local DOWNLOAD_ID="" | ||||||
|     local DOWNLOAD_URL="" |     local DOWNLOAD_URL="" | ||||||
|     local RELEASES="" |  | ||||||
| 
 | 
 | ||||||
|     RELEASES=$(releases_windows) |     validate_release "releases_windows" | ||||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then |  | ||||||
|         echo "ERROR! Windows ${RELEASE} is not supported." |  | ||||||
|         echo "${RELEASES}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     echo "Getting Windows ${RELEASE} URL..." |     echo "Getting Windows ${RELEASE} URL..." | ||||||
|     WINDOWS_VERSIONS=$(wget -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))') |     WINDOWS_VERSIONS=$(wget -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))') | ||||||
|  | @ -827,7 +766,7 @@ function get_windows() { | ||||||
|     # Only check the integrity is SHA1 is available. |     # Only check the integrity is SHA1 is available. | ||||||
|     if [ -n "${DOWNLOAD_SHA1}" ]; then |     if [ -n "${DOWNLOAD_SHA1}" ]; then | ||||||
|       echo "${DOWNLOAD_SHA1}  ${FILE_NAME}" > "${VM_PATH}/SHA1SUMS" |       echo "${DOWNLOAD_SHA1}  ${FILE_NAME}" > "${VM_PATH}/SHA1SUMS" | ||||||
|       echo "Checking SHA1SUMS..." | 
 | ||||||
|       cd "${VM_PATH}" |       cd "${VM_PATH}" | ||||||
|       if ! sha1sum --check SHA1SUMS --ignore-missing --status; then |       if ! sha1sum --check SHA1SUMS --ignore-missing --status; then | ||||||
|           echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA1SUMS. Try running 'quickget' again." |           echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA1SUMS. Try running 'quickget' again." | ||||||
|  | @ -838,7 +777,6 @@ function get_windows() { | ||||||
|       cd .. |       cd .. | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     echo "Downloading virtio-win.iso..." |  | ||||||
|     web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}" |     web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}" | ||||||
| 
 | 
 | ||||||
|     if [ ! -e "${VM_PATH}/unattended.iso" ]; then |     if [ ! -e "${VM_PATH}/unattended.iso" ]; then | ||||||
|  | @ -855,7 +793,6 @@ function get_windows() { | ||||||
|         esac |         esac | ||||||
|     fi |     fi | ||||||
|     make_vm_config "${FILE_NAME}" "virtio-win.iso" |     make_vm_config "${FILE_NAME}" "virtio-win.iso" | ||||||
| 
 |  | ||||||
|     start_vm_info |     start_vm_info | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue