struct(tools): checksum generator script

This commit is contained in:
Asif Bacchus 2021-07-27 17:08:55 -06:00
parent a6107f7e25
commit 16f302c3fd

View File

@ -0,0 +1,28 @@
#!/bin/sh
#
# generate checksums from provided path suitable for use by 'update.sh'
#
# check for missing path to helper files, otherwise strip trailing slash
if [ -z "$1" ]; then
printf "\nPlease supply path to helper files. Exiting.\n\n"
exit 1
fi
srcDir="${1%/}"
# verify path exists and is accessible
if ! [ -d "$srcDir" ]; then
printf "\nUnable to find or read supplied path to helper files. Exiting.\n\n"
exit 1
fi
# generate checksum file
\rm -f "${srcDir}/checksums.sha256"
find "${srcDir}/" -type f -exec sha256sum {} + >>"${srcDir}/checksums.sha256"
sed -i "s+$srcDir/++g" "${srcDir}/checksums.sha256"
# exit gracefully
exit 0
#EOF