Skip to content

Instantly share code, notes, and snippets.

@dzabel
Last active May 30, 2016 14:25
Show Gist options
  • Save dzabel/6743f5a0a9e00f4634ce42f6caff518e to your computer and use it in GitHub Desktop.
Save dzabel/6743f5a0a9e00f4634ce42f6caff518e to your computer and use it in GitHub Desktop.
filedownload - verify checksum
#!/bin/bash
DL_URL='http://my-remote-url'
# assumes that for each file a same file with .sha256 extension exists
DUMPS="dlfile1 dlfile2"
for i in ${DUMPS}; do
while [ "x$(curl --silent "${DL_URL}/${i}.sha256" -o ${i}.sha256 && cat ${i}.sha256 | cut -d ' ' -f 1)" != "x$(sha256sum "${i}" 2>/dev/null | cut -d ' ' -f 1)" ]; do
echo "Downloading file ${i} ..."
curl --silent -L -O ${DL_URL}/${i}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment