ValidateDownloadedTarballChecksum

nicolaw 2nd August 2018 at 12:19pm
Bash CodeSnippets
declare file_sha256=$({
    curl -sL "$file_url" \
      | tee >(sha256sum | cut -f 1 -d ' ' >&3 ) \
      | tar -xjC /dest/dir/;
  } 3>&1)
[[ "$file_sha256" = "$(curl -sL "$sha256_url" | cut -f 1 -d ' ')" ]] \
  || { >&2 echo 'Checksum mismatch!'; exit 1; }