From c11f8d86e489c8f95aad3fc74b5b0142f1cd6617 Mon Sep 17 00:00:00 2001 From: Richard Gee Date: Sat, 7 Jul 2018 14:53:24 +0100 Subject: [PATCH] Add graceful degradation for sha_cmd in get.sh The earlier choice of using shasum was made for broadest support reasons. However the breadth of support could be broader still by introducing graceful degradation to get.sh. This change defaults the command to be used to sha256sum and reverts to shasum -a 256 if the default isnt found. Signed-off-by: Richard Gee --- get.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/get.sh b/get.sh index cf510a495..f1f4f1aa6 100755 --- a/get.sh +++ b/get.sh @@ -30,12 +30,20 @@ hasCli() { fi } + checkHash(){ - if [ -x "$(command -v shasum)" ]; then + + sha_cmd="sha256sum" + + if [ ! -x "$(command -v $sha_cmd)" ]; then + sha_cmd="shasum -a 256" + fi + + if [ -x "$(command -v $sha_cmd)" ]; then targetFileDir=${targetFile%/*} - (cd $targetFileDir && curl -sSL $url.sha256|shasum -c -s) + (cd $targetFileDir && curl -sSL $url.sha256|$sha_cmd -c -s) if [ "$?" != "0" ]; then rm $targetFile @@ -108,7 +116,7 @@ getPackage() { else echo - echo "Running as root - Attemping to move faas-cli to /usr/local/bin" + echo "Running as root - Attempting to move faas-cli to /usr/local/bin" mv $targetFile /usr/local/bin/faas-cli