For use with the How To Checksum A Dapp Medium article.
This example is for the dapp https://launchpad.ethereum.org, currently built from git commit c2e194e on 2020–11-04.
$ export DAPP_URL=https://launchpad.ethereum.org
$ export DAPP_DIR=$(echo "$DAPP_URL" | sed -e "s/\:\/\//__/" -e "s/\//__/")
$ date +%FT%H:%M:%S | awk -v dapp_dir="$DAPP_DIR" '{print dapp_dir "__" $1}' \
| xargs mv $DAPP_DIR 2>/dev/null
$ wget -q -r --no-parent -k --restrict-file-names=unix --no-host-directories -P $DAPP_DIR $DAPP_URL \
&& find $DAPP_DIR -type f -print0 | xargs -0 -n1 shasum -a 384 \
| sort -k2 | sed -e "s/$DAPP_DIR//" \
| awk '{print "\"" $2 "\"" "," "\"" $1 "\"";}' > dapp_file_checksums.csv \
&& shasum -a 384 dapp_file_checksums.csv | awk 'NR==1{print $1}'
364fdd3eee6af86f43877be7547a4ddafe9795dd4f73b85fe3a577aec96ca09fba61ce04d48786670c5ac3416060c1b1
The following breaks the full command down into its component parts in order to understand how it works. This can also help you understand why the dapp checksum may be failing to generate the correct result.
$ export DAPP_URL=https://launchpad.ethereum.org
$ export DAPP_DIR=$(echo "$DAPP_URL" | sed -e "s/\:\/\//__/" -e "s/\//__/")
$ date +%FT%H:%M:%S | awk -v dapp_dir="$DAPP_DIR" '{print dapp_dir "__" $1}' \
| xargs mv $DAPP_DIR 2>/dev/null
$ wget -q -r --no-parent -k --restrict-file-names=unix --no-host-directories -P $DAPP_DIR $DAPP_URL
The above command results in a directory containing the files from the website:
$ ls -la
https__launchpad.ethereum.org
$ find $DAPP_DIR -type f | sort | sed -e "s/$DAPP_DIR//"
/apple-touch-icon.png
/favicon-16x16.png
/favicon-32x32.png
/index.html
/robots.txt
/static/css/2.d9ee7e2f.chunk.css
/static/js/2.d0a1f97f.chunk.js
/static/js/main.ccc0b010.chunk.js
$ find $DAPP_DIR -type f -print0 | xargs -0 -n1 shasum -a 384 \
| sort -k2 | sed -e "s/$DAPP_DIR//"
The above command results in checksums on the contents of each file from the downloaded website:
856832c71f630cc4983338e70b309a9cc8c9e55a8c0069a8bc6c65650038237a5c8b2ed3dccd4a9fbaca53ea63459f58 /apple-touch-icon.png
6d5fe7dbc6995dda924df92fb7bbbec5f540ff6369816aa743958a47f8b54c904c7a5b90ab0bef5b57858bebbfe17ee5 /favicon-16x16.png
d4682e89467618c5be091b5773e86a5d04e5a8f7849a09a9699daedd558ca970cf42904fc5440038699bbd9127ca481b /favicon-32x32.png
386ed2c468b28501a2c3a36fe471283c09e5c3716c0237839ef8f79959025394d0dd0e7a592e31100ba9db50b58ad5cf /index.html
386ed2c468b28501a2c3a36fe471283c09e5c3716c0237839ef8f79959025394d0dd0e7a592e31100ba9db50b58ad5cf /robots.txt
d6b56101048deae9b65796cf4d388fa196b93670b3fa79eabd0cf183ddfa23ace39556988ff23aa43dd41a1077fee111 /static/css/2.d9ee7e2f.chunk.css
32e22c3bad09f7c0d531ab3681b041f6394e0bf21f8f8c9659f8e495df1442e612e0cdee8088f01a9b05527fcf881041 /static/js/2.d0a1f97f.chunk.js
74b559835c5abc1e87d29d0461a412fabae612eaef143cc631cd88f8944d39f5cc453d069762a9a7498bd0b38741280a /static/js/main.ccc0b010.chunk.js
$ find $DAPP_DIR -type f -print0 | xargs -0 -n1 shasum -a 384 \
| sort -k2 | sed -e "s/$DAPP_DIR//" \
| awk '{print "\"" $2 "\"" "," "\"" $1 "\"";}' > dapp_file_checksums.csv
Results in a CSV file containing file names and checksums of their contents:
$ cat dapp_file_checksums.csv
"/apple-touch-icon.png","856832c71f630cc4983338e70b309a9cc8c9e55a8c0069a8bc6c65650038237a5c8b2ed3dccd4a9fbaca53ea63459f58"
"/favicon-16x16.png","6d5fe7dbc6995dda924df92fb7bbbec5f540ff6369816aa743958a47f8b54c904c7a5b90ab0bef5b57858bebbfe17ee5"
"/favicon-32x32.png","d4682e89467618c5be091b5773e86a5d04e5a8f7849a09a9699daedd558ca970cf42904fc5440038699bbd9127ca481b"
"/index.html","386ed2c468b28501a2c3a36fe471283c09e5c3716c0237839ef8f79959025394d0dd0e7a592e31100ba9db50b58ad5cf"
"/robots.txt","386ed2c468b28501a2c3a36fe471283c09e5c3716c0237839ef8f79959025394d0dd0e7a592e31100ba9db50b58ad5cf"
"/static/css/2.d9ee7e2f.chunk.css","d6b56101048deae9b65796cf4d388fa196b93670b3fa79eabd0cf183ddfa23ace39556988ff23aa43dd41a1077fee111"
"/static/js/2.d0a1f97f.chunk.js","32e22c3bad09f7c0d531ab3681b041f6394e0bf21f8f8c9659f8e495df1442e612e0cdee8088f01a9b05527fcf881041"
"/static/js/main.ccc0b010.chunk.js","74b559835c5abc1e87d29d0461a412fabae612eaef143cc631cd88f8944d39f5cc453d069762a9a7498bd0b38741280a"
$ shasum -a 384 dapp_file_checksums.csv | awk 'NR==1{print $1}'
364fdd3eee6af86f43877be7547a4ddafe9795dd4f73b85fe3a577aec96ca09fba61ce04d48786670c5ac3416060c1b1