Skip to content

Instantly share code, notes, and snippets.

@kumbasar
Last active January 22, 2019 06:00
Show Gist options
  • Save kumbasar/303b32d2aea5d635b3c1d5d544330d93 to your computer and use it in GitHub Desktop.
Save kumbasar/303b32d2aea5d635b3c1d5d544330d93 to your computer and use it in GitHub Desktop.
A script which generates the checksum files for the Artifactory
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No file supplied."
echo "Example: ./checksum.sh wget_1.0.1_amd64.deb"
exit -1
fi
declare -a checksum=("md5sum" "sha256sum" "sha1sum")
## now loop through the above array
for i in "${checksum[@]}"
do
echo "$i"
# or do whatever with individual element of the array
$i $1 | awk '{print $1}' | tee ${1}.${i::-3}
done
@kumbasar
Copy link
Author

/home/kumbasar/test$ ./checksum.sh test.deb
md5sum
61e59f13b101aec95ad556882b316566
sha256sum
6062e9357870781cdba047109a5916d1d5a87667a49c8f497642eab5a9e2b9d5
sha1sum
54dc7e9108e1c29f125b7f5dc1ff6bb50e91fd2b
/home/kumbasar/test$ ls test*
test.deb  test.deb.md5  test.deb.sha1  test.deb.sha256
/home/kumbasar/test$
/home/kumbasar/test$ curl -T test.deb "http://localhost:8081/artifactory/dev/test/"
/home/kumbasar/test$ curl -T test.deb.md5 "http://localhost:8081/artifactory/dev/test/"
/home/kumbasar/test$ curl -T test.deb.sha1 "http://localhost:8081/artifactory/dev/test/"
/home/kumbasar/test$ curl -T test.deb.sha256 "http://localhost:8081/artifactory/dev/test/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment