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
				
			
		
							
								
								
									
										10
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
										
									
									
									
								
							|  | @ -226,6 +226,16 @@ disk_img="debian-bullseye/disk.qcow2" | ||||||
| iso="debian-bullseye/firmware-11.0.0-amd64-DVD-1.iso" | iso="debian-bullseye/firmware-11.0.0-amd64-DVD-1.iso" | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | If you already have a collection of ISOs downloaded you can have `quickget` find and copy your existing file into the VM directory. | ||||||
|  | 
 | ||||||
|  | ~~~~ | ||||||
|  | --isodir                : base path beneath which to find local ISO copy | ||||||
|  |                                        if a matching file is found it will be copied to the VM directory | ||||||
|  | --localiso              : optional local ISO filename - defaults to target filename | ||||||
|  | ~~~~ | ||||||
|  | 
 | ||||||
|  | `quickget` will then continue to `wget` or `zsync` using that file as a prior copy.  If the target file exists in the VM directory `quickget` will raise an error if you run it with `--isodir` | ||||||
|  | 
 | ||||||
|   * Use `quickemu` to start the virtual machine: |   * Use `quickemu` to start the virtual machine: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
|  |  | ||||||
							
								
								
									
										100
									
								
								quickget
									
										
									
									
									
								
							
							
						
						
									
										100
									
								
								quickget
									
										
									
									
									
								
							|  | @ -536,9 +536,30 @@ function check_hash() { | ||||||
|     fi |     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() { | function web_get() { | ||||||
|     local DIR="${2}" |     local DIR="${2}" | ||||||
|     local FILE="" |     local FILE="" | ||||||
|  |     local LOCALFILE="" | ||||||
|     local URL="${1}" |     local URL="${1}" | ||||||
| 
 | 
 | ||||||
|     if [ -n "${3}" ]; then |     if [ -n "${3}" ]; then | ||||||
|  | @ -551,6 +572,7 @@ function web_get() { | ||||||
|       echo "ERROR! Unable to create directory ${DIR}" |       echo "ERROR! Unable to create directory ${DIR}" | ||||||
|       exit 1 |       exit 1 | ||||||
|     fi |     fi | ||||||
|  |     copy_local | ||||||
| 
 | 
 | ||||||
|     if command -v aria2c > /dev/null; then |     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 |         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 |           exit 1 | ||||||
|         fi |         fi | ||||||
|     fi |     fi | ||||||
|  | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function zsync_get() { | function zsync_get() { | ||||||
|     local DIR="${2}" |     local DIR="${2}" | ||||||
|     local FILE="" |     local FILE="" | ||||||
|  |     local LOCALFILE="" | ||||||
|     local OUT="" |     local OUT="" | ||||||
|     local URL="${1}" |     local URL="${1}" | ||||||
|     FILE="${URL##*/}" |     FILE="${URL##*/}" | ||||||
|  | @ -589,6 +613,8 @@ function zsync_get() { | ||||||
|         exit 1 |         exit 1 | ||||||
|       fi |       fi | ||||||
| 
 | 
 | ||||||
|  |     copy_local | ||||||
|  | 
 | ||||||
|       if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then |       if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then | ||||||
|           echo "ERROR! Failed to download ${URL}.zsync" |           echo "ERROR! Failed to download ${URL}.zsync" | ||||||
|           exit 1 |           exit 1 | ||||||
|  | @ -1888,7 +1914,25 @@ function get_windows() { | ||||||
|     esac |     esac | ||||||
|     make_vm_config "${FILE_NAME}" "virtio-win.iso" |     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 | trap cleanup EXIT | ||||||
| 
 | 
 | ||||||
| if ((BASH_VERSINFO[0] < 4)) | if ((BASH_VERSINFO[0] < 4)) | ||||||
|  | @ -1900,18 +1944,44 @@ fi | ||||||
| LANGS=() | LANGS=() | ||||||
| languages_windows | 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 | if [ -n "${1}" ]; then | ||||||
|     OS="${1,,}" |     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 | else | ||||||
|     echo "ERROR! You must specify an operating system:" |     echo "ERROR! You must specify an operating system:" | ||||||
|     os_support |     os_support | ||||||
|  | @ -2133,3 +2203,11 @@ else | ||||||
|     fi |     fi | ||||||
|     exit 1 |     exit 1 | ||||||
| fi | 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