Created
February 13, 2016 14:01
-
-
Save mrinalwadhwa/7ef2fa6f58ad894f6d0a to your computer and use it in GitHub Desktop.
Script to download and check hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Usage: | |
# download.sh URL DEST MD5 | |
# | |
# Example: | |
# download.sh \ | |
# http://a.mbbsindia.com/hbase/1.1.3/hbase-1.1.3-bin.tar.gz \ | |
# /var/downloads/cache/1c9f52d89cf665ef35f101cb8f2b57e4 \ | |
# 1c9f52d89cf665ef35f101cb8f2b57e4 | |
# | |
url="$1" | |
dest_path="$2" | |
expected_hash="$3" | |
curl -L# -o "$dest_path" "$url" | |
generated_hash=`md5 "$dest_path" | cut -d' ' -f4` | |
if [ "$generated_hash" == "$expected_hash" ]; then | |
exit 0 | |
else | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment