From ef94ff64ff7acf31726b862ecb41b9f2e68e6e2a Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 19 Oct 2021 20:33:07 +0100 Subject: [PATCH] check_hash() will automatically add the VM_PATH and derive the hash algorithm --- quickget | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/quickget b/quickget index a57d855..feca36f 100755 --- a/quickget +++ b/quickget @@ -403,9 +403,17 @@ function check_hash() { local iso="" local hash="" local hash_algo="" - iso="${1}" + iso="${VM_PATH}/${1}" hash="${2}" - hash_algo="${3}" + + # Guess the hash algorithm by the hash length + case ${#hash} in + 32) hash_algo=md5sum;; + 40) hash_algo=sha1sum;; + 64) hash_algo=sha256sum;; + *) echo "WARNING! Can't guess hash algorithm, not checking ${iso} hash." + return;; + esac echo -n "Checking ${iso} with ${hash_algo}... " if ! echo "${hash} ${iso}" | ${hash_algo} --check --status; then