From 94a84109a2f87db1365cf1f86deb51076ee2cad0 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 18 Feb 2022 15:17:00 -0500 Subject: [PATCH 1/2] add os --- scripts/install.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 75f776a..e3a6dc7 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -28,7 +28,7 @@ check_cmd() { } # Check if the commands to be used exist. -for cmd in curl unzip; do +for cmd in curl unzip awk; do check_cmd $cmd done @@ -36,24 +36,27 @@ get_latest_release_number() { curl --silent "https://github.com/sourceplusplus/interface-cli/releases/latest" | sed 's#.*tag/\(.*\)\".*#\1#' } +# Convert the string to lower case. +OS=$(echo $OS | awk '{print tolower($0)}') + # Get the latest version of spp-cli. VERSION=$(get_latest_release_number) echo "Installing spp-cli $VERSION" # Download the binary package. -curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-linux64.zip" > /dev/null -if [ -f "spp-cli-$VERSION-linux64.zip" ]; then - unzip -q spp-cli-$VERSION-linux64.zip +curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-${OS}64.zip" > /dev/null +if [ -f "spp-cli-$VERSION-${OS}64.zip" ]; then + unzip -q spp-cli-$VERSION-${OS}64.zip echo "Adding spp-cli to your PATH" # Add spp-cli to the environment variable PATH. sudo mv spp-cli /usr/local/bin/spp-cli # Delete unnecessary files. - rm "./spp-cli-$VERSION-linux64.zip" + rm "./spp-cli-$VERSION-${OS}64.zip" echo "Installation complete." echo "Type 'spp-cli --help' to get more information." else - abort "Failed to download spp-cli-$VERSION-linux64.zip" + abort "Failed to download spp-cli-$VERSION-${OS}64.zip" fi From 66378519d00013a7a44208f62c586206c3334d74 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 18 Feb 2022 15:39:49 -0500 Subject: [PATCH 2/2] refactor --- scripts/install.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index e3a6dc7..a743949 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -43,20 +43,22 @@ OS=$(echo $OS | awk '{print tolower($0)}') VERSION=$(get_latest_release_number) echo "Installing spp-cli $VERSION" +ARCHIVE_NAME="spp-cli-$VERSION-${OS}64.zip" + # Download the binary package. -curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-${OS}64.zip" > /dev/null -if [ -f "spp-cli-$VERSION-${OS}64.zip" ]; then - unzip -q spp-cli-$VERSION-${OS}64.zip +curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/$ARCHIVE_NAME" > /dev/null +if [ -f "$ARCHIVE_NAME" ]; then + unzip -q $ARCHIVE_NAME echo "Adding spp-cli to your PATH" # Add spp-cli to the environment variable PATH. sudo mv spp-cli /usr/local/bin/spp-cli # Delete unnecessary files. - rm "./spp-cli-$VERSION-${OS}64.zip" + rm "./$ARCHIVE_NAME" echo "Installation complete." echo "Type 'spp-cli --help' to get more information." else - abort "Failed to download spp-cli-$VERSION-${OS}64.zip" + abort "Failed to download $ARCHIVE_NAME" fi