Skip to content

Instantly share code, notes, and snippets.

@antontsv
Last active March 12, 2020 07:35
Show Gist options
  • Save antontsv/a2287051b046fd2ca7989e11faa64b5a to your computer and use it in GitHub Desktop.
Save antontsv/a2287051b046fd2ca7989e11faa64b5a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
fatal(){
echo "$*";
exit 1;
}
OS=$(uname -s)
hashsum="expected hash sum will be here"
shasum_cmd="echo 'command for sha 256 will be set here'"
tool="/tmp/urlsh"
if [ "$OS" = "Darwin" ]; then
#  Mac OS
shasum_cmd="/usr/bin/shasum -a 256"
curl -Ls -o "$tool" "https://antontsv.keybase.pub/macos-urlsh?dl=1"
hashsum="63a73df4d76319697e77bae8a4145bffe0c13ec7fb9f56066210937d04a51c02"
else
shasum_cmd="/usr/bin/sha256sum"
curl -Ls -o "$tool" "https://antontsv.keybase.pub/urlsh?dl=1"
hashsum="dfabd175028e708f96b0573947be10fe9a17818f5b3b46c91bcf19ffaa68c4ea"
fi;
if [ "$($shasum_cmd $tool | cut -d ' ' -f1 )" != "$hashsum" ];then
rm -rf "$tool"
echo "Downloaded urlsh tool does not have expected sha256."
fatal "Cannot trust the tool."
fi;
chmod u+x "$tool"
echo "**** Now you can run: ****"
echo "$tool https://git.io/all.files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment