diff --git a/README.md b/README.md index c744d8a..7da5e7c 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,16 @@ disk_img="debian-bullseye/disk.qcow2" 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: ```bash diff --git a/quickget b/quickget index 26eca79..82de2ea 100755 --- a/quickget +++ b/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] (