Refactor existing hash checking to use check_hash()
This commit is contained in:
parent
e1d15d4f04
commit
b71fab5798
43
quickget
43
quickget
@ -555,9 +555,9 @@ function get_freebsd() {
|
|||||||
function get_fedora() {
|
function get_fedora() {
|
||||||
local FEDORA_RELEASE=""
|
local FEDORA_RELEASE=""
|
||||||
local FEDORA_VERSIONS=""
|
local FEDORA_VERSIONS=""
|
||||||
|
local HASH=""
|
||||||
local ISO=""
|
local ISO=""
|
||||||
local URL=""
|
local URL=""
|
||||||
local SHA256SUM=""
|
|
||||||
local VERSION_NUM=""
|
local VERSION_NUM=""
|
||||||
|
|
||||||
validate_release "releases_fedora"
|
validate_release "releases_fedora"
|
||||||
@ -573,21 +573,10 @@ function get_fedora() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
URL=$(echo "${FEDORA_RELEASE}" | jq -r '.link')
|
URL=$(echo "${FEDORA_RELEASE}" | jq -r '.link')
|
||||||
SHA256SUM=$(echo "${FEDORA_RELEASE}" | jq -r '.sha256')
|
HASH=$(echo "${FEDORA_RELEASE}" | jq -r '.sha256')
|
||||||
|
|
||||||
make_vm_dir
|
make_vm_dir
|
||||||
web_get "${URL}" "${VM_PATH}"
|
web_get "${URL}" "${VM_PATH}"
|
||||||
|
check_hash "${VM_PATH}/${ISO}" "${HASH}" sha256sum
|
||||||
echo "Checking SHA256SUMS..."
|
|
||||||
cd "${VM_PATH}"
|
|
||||||
if ! echo "${SHA256SUM} ${ISO}" | sha256sum --check --status; then
|
|
||||||
echo "ERROR! ${ISO} doesn't match ${SHA256SUM}. Try running 'quickget' again."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "All good."
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
make_vm_config "${ISO}"
|
make_vm_config "${ISO}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,6 +696,7 @@ function get_popos() {
|
|||||||
function get_ubuntu() {
|
function get_ubuntu() {
|
||||||
local DEVEL="daily-live"
|
local DEVEL="daily-live"
|
||||||
local ISO=""
|
local ISO=""
|
||||||
|
local HASH=""
|
||||||
local PROJECT=""
|
local PROJECT=""
|
||||||
local URL=""
|
local URL=""
|
||||||
|
|
||||||
@ -735,20 +725,13 @@ function get_ubuntu() {
|
|||||||
|
|
||||||
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')
|
||||||
|
HASH=$(cat "${VM_PATH}/SHA256SUMS" | cut -d' ' -f1)
|
||||||
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"
|
||||||
else
|
else
|
||||||
web_get "${URL}/${ISO}" "${VM_PATH}"
|
web_get "${URL}/${ISO}" "${VM_PATH}"
|
||||||
echo "Checking SHA256SUMS..."
|
check_hash "${VM_PATH}/${ISO}" "${HASH}" sha256sum
|
||||||
cd "${VM_PATH}"
|
|
||||||
if ! sha256sum --check SHA256SUMS --ignore-missing --status; then
|
|
||||||
echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA256SUMS. Try running 'quickget' again."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "All good."
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
make_vm_config "${ISO}"
|
make_vm_config "${ISO}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -796,19 +779,9 @@ function get_windows() {
|
|||||||
echo "Downloading ${WINDOWS_NAME}..."
|
echo "Downloading ${WINDOWS_NAME}..."
|
||||||
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
|
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
|
||||||
|
|
||||||
# Windows 10 doesn't include a SHA1 sum
|
# Windows 10 doesn't include a SHA1, so only check the integrity if the 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"
|
check_hash "${VM_PATH}/${FILE_NAME}" "${DOWNLOAD_SHA1}" sha1sum
|
||||||
|
|
||||||
cd "${VM_PATH}"
|
|
||||||
if ! sha1sum --check SHA1SUMS --ignore-missing --status; then
|
|
||||||
echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA1SUMS. Try running 'quickget' again."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "All good."
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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}"
|
||||||
|
Loading…
Reference in New Issue
Block a user