check_hash() will automatically add the VM_PATH and derive the hash algorithm
This commit is contained in:
parent
e24f34ad9d
commit
ef94ff64ff
12
quickget
12
quickget
@ -403,9 +403,17 @@ function check_hash() {
|
|||||||
local iso=""
|
local iso=""
|
||||||
local hash=""
|
local hash=""
|
||||||
local hash_algo=""
|
local hash_algo=""
|
||||||
iso="${1}"
|
iso="${VM_PATH}/${1}"
|
||||||
hash="${2}"
|
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}... "
|
echo -n "Checking ${iso} with ${hash_algo}... "
|
||||||
if ! echo "${hash} ${iso}" | ${hash_algo} --check --status; then
|
if ! echo "${hash} ${iso}" | ${hash_algo} --check --status; then
|
||||||
|
Loading…
Reference in New Issue
Block a user