mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Use local isos (#314)
* Start adding params for existing isos * Merge parameter handling code * initial testing seems reasonable Note that if copying files in, "wget -c " will assume smaller-than-remote files are parts and continue so likely will cause hashing failures or if no hash check then corrupt isos. * Added usage for --help * Usage enhanced and added to Readme * spurios unused cruft removed
This commit is contained in:
		
							parent
							
								
									14ae0d53a2
								
							
						
					
					
						commit
						328b109cff
					
				
					 2 changed files with 99 additions and 11 deletions
				
			
		
							
								
								
									
										100
									
								
								quickget
									
										
									
									
									
								
							
							
						
						
									
										100
									
								
								quickget
									
										
									
									
									
								
							|  | @ -536,9 +536,30 @@ function check_hash() { | |||
|     fi | ||||
| } | ||||
| 
 | ||||
| function copy_local(){ | ||||
|   if [ -n "${ISODIR}" ]; then | ||||
|     # use supplied filename or default to original distro ISO name | ||||
|       if [ -z ${LOCALISO} ]; then | ||||
|         LOCALISO=${FILE} | ||||
|       fi | ||||
|       LOCALFILE=$(find ${ISODIR} -type f -name "${LOCALISO}" -print -quit ) | ||||
|       #echo got local file "${LOCALFILE}" | ||||
|       if [ -f "${DIR}/${FILE}" ]; then | ||||
|         echo "ERROR! File Exists - not copying over local file" | ||||
|         echo "Move it out of the way to replace it with a local file" | ||||
|         exit 1 | ||||
|       else | ||||
|         cp -pv "${LOCALFILE}" ${DIR}/${FILE} | ||||
|       # if ! ; then echo ERROR! Failed to copy ${LOCALFILE}" to ${DIR}/${FILE}" | ||||
|       fi | ||||
|       #exit 0 # while testing | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| function web_get() { | ||||
|     local DIR="${2}" | ||||
|     local FILE="" | ||||
|     local LOCALFILE="" | ||||
|     local URL="${1}" | ||||
| 
 | ||||
|     if [ -n "${3}" ]; then | ||||
|  | @ -551,6 +572,7 @@ function web_get() { | |||
|       echo "ERROR! Unable to create directory ${DIR}" | ||||
|       exit 1 | ||||
|     fi | ||||
|     copy_local | ||||
| 
 | ||||
|     if command -v aria2c > /dev/null; then | ||||
|         if ! aria2c -x16 --continue=true --summary-interval=0 --download-result=hide --console-log-level=error "${URL}" -o "${DIR}/${FILE}"; then | ||||
|  | @ -565,11 +587,13 @@ function web_get() { | |||
|           exit 1 | ||||
|         fi | ||||
|     fi | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| function zsync_get() { | ||||
|     local DIR="${2}" | ||||
|     local FILE="" | ||||
|     local LOCALFILE="" | ||||
|     local OUT="" | ||||
|     local URL="${1}" | ||||
|     FILE="${URL##*/}" | ||||
|  | @ -589,6 +613,8 @@ function zsync_get() { | |||
|         exit 1 | ||||
|       fi | ||||
| 
 | ||||
|     copy_local | ||||
| 
 | ||||
|       if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then | ||||
|           echo "ERROR! Failed to download ${URL}.zsync" | ||||
|           exit 1 | ||||
|  | @ -1888,7 +1914,25 @@ function get_windows() { | |||
|     esac | ||||
|     make_vm_config "${FILE_NAME}" "virtio-win.iso" | ||||
| } | ||||
| 
 | ||||
| function usage() { | ||||
|   echo | ||||
|   echo "Usage" | ||||
|   echo "  $0 [--isodir] [--localiso] [--list | --json] <OS> <Release> (<Option>)" | ||||
|   echo | ||||
|   echo If you omit parameters a list of supported OS options will be provided. | ||||
|   echo If you omit a Release a list of supported releases for the selected OS will be  given. | ||||
|   echo | ||||
|   echo "You can also pass optional parameters" | ||||
|   echo | ||||
|   echo "  --list                  : print a csv list of supported guest" | ||||
|   echo "  --json                  : print a json list of supported guest" | ||||
|   echo "  --isodir                : base path beneath which to find local ISO copy | ||||
|                                        if a matching file is found it will be copied to the VM directory" | ||||
|   echo "  --localiso              : local ISO filename - defaults to target filename" | ||||
|   echo "  --help                  : Print usage (this)" | ||||
|   echo "  --version               : Print version" | ||||
|   exit 1 | ||||
| } | ||||
| trap cleanup EXIT | ||||
| 
 | ||||
| if ((BASH_VERSINFO[0] < 4)) | ||||
|  | @ -1900,18 +1944,44 @@ fi | |||
| LANGS=() | ||||
| languages_windows | ||||
| 
 | ||||
| # handle parameters | ||||
| 
 | ||||
| # Take command line arguments | ||||
| #if [ $# -lt 1 ]; then | ||||
| #    usage | ||||
| #    exit 0 | ||||
| #else | ||||
|     while [ $# -gt 0 ]; do | ||||
|         case "${1}" in | ||||
|           -isodir|--isodir) | ||||
|             ISODIR="${2}" | ||||
|             shift | ||||
|             shift;; | ||||
|           -localiso|--localiso) | ||||
|             LOCALISO="${2}" | ||||
|             shift | ||||
|             shift;; | ||||
|          -h|--h|-help|--help) | ||||
|             usage | ||||
|             exit 0;; | ||||
|          -l|--l|-list|--list|list|list_csv) | ||||
|             list_csv;; | ||||
|           -j|--j|-json|--json|list_json) | ||||
|             list_json;; | ||||
|           -v|--v|-version|--version|version ) | ||||
|              whereIam=$(dirname "${BASH_SOURCE[0]}") | ||||
|               quickemu_version=$( "${whereIam}"/quickemu --version) | ||||
|               echo "Quickemu Version: ${quickemu_version}" | ||||
|               exit 0;; | ||||
|           test*) | ||||
|              echo "you are just testing | ||||
|              ISODIR:  ${ISODIR} | ||||
|              LOCALISO: ${LOCALISO}" | ||||
|              exit 0;; | ||||
|           *) | ||||
| 
 | ||||
| if [ -n "${1}" ]; then | ||||
|     OS="${1,,}" | ||||
|     if [ "${OS}" == "list" ] || [ "${OS}" == "list_csv" ]; then | ||||
|         list_csv | ||||
|     elif [ "${OS}" == "list_json" ]; then | ||||
|         list_json | ||||
|     elif [ "${OS}" == "--version" ] || [ "${OS}" == "-version" ] || [ "${OS}" == "version" ]; then | ||||
|       whereIam=$(dirname "${BASH_SOURCE[0]}") | ||||
|       quickemu_version=$( "${whereIam}"/quickemu --version) | ||||
|       echo "Quickemu Version: ${quickemu_version}" | ||||
|       exit 0 | ||||
|     fi | ||||
| else | ||||
|     echo "ERROR! You must specify an operating system:" | ||||
|     os_support | ||||
|  | @ -2133,3 +2203,11 @@ else | |||
|     fi | ||||
|     exit 1 | ||||
| fi | ||||
| ;; | ||||
|    esac | ||||
|     done | ||||
|     if [ $# == 0 ]; then | ||||
|       echo "Error: You must supply an OS!" | ||||
|       os_support | ||||
|       exit 1 | ||||
| fi | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue