Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ hasCli() {
fi
}

checkHash(){
if [ -x "$(command -v shasum)" ]; then

targetFileDir=${targetFile%/*}

(cd $targetFileDir && curl -sSL $url.sha256|shasum -c -s)

if [ "$?" != "0" ]; then
rm $targetFile
echo "Binary checksum didn't match. Exiting"
exit 1
fi
fi
}

getPackage() {
uname=$(uname)
Expand All @@ -56,10 +70,10 @@ getPackage() {
;;
esac

targetFile="/tmp/faas-cli"
targetFile="/tmp/faas-cli$suffix"

if [ "$userid" != "0" ]; then
targetFile="$(pwd)/faas-cli"
targetFile="$(pwd)/faas-cli$suffix"
fi

if [ -e $targetFile ]; then
Expand All @@ -69,10 +83,12 @@ getPackage() {
url=https://github.com/openfaas/faas-cli/releases/download/$version/faas-cli$suffix
echo "Downloading package $url as $targetFile"

curl -sSL $url > $targetFile
curl -sSL $url --output $targetFile

if [ "$?" = "0" ]; then

checkHash

chmod +x $targetFile

echo "Download complete."
Expand All @@ -85,7 +101,7 @@ getPackage() {
echo "== following commands may need to be run manually =="
echo "========================================================="
echo
echo " sudo cp faas-cli /usr/local/bin/"
echo " sudo cp faas-cli$suffix /usr/local/bin/faas-cli"
echo " sudo ln -sf /usr/local/bin/faas-cli /usr/local/bin/faas"
echo

Expand All @@ -94,7 +110,7 @@ getPackage() {
echo
echo "Running as root - Attemping to move faas-cli to /usr/local/bin"

mv $targetFile /usr/local/bin/
mv $targetFile /usr/local/bin/faas-cli

if [ "$?" = "0" ]; then
echo "New version of faas-cli installed to /usr/local/bin"
Expand All @@ -108,6 +124,8 @@ getPackage() {
ln -s /usr/local/bin/faas-cli /usr/local/bin/faas
echo "Creating alias 'faas' for 'faas-cli'."
fi

faas-cli version
fi
fi
}
Expand Down