From e5d74aca4ee2f32f2039c5d0ec1786097e250b42 Mon Sep 17 00:00:00 2001 From: Zachary Proser Date: Mon, 2 May 2022 08:30:00 -0400 Subject: [PATCH] Simplify install.sh script --- install.sh | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 6368e3d..a391d18 100755 --- a/install.sh +++ b/install.sh @@ -2,22 +2,18 @@ set -e binary_name="procrastiproxy" # Determine architecture -if [[ $(uname -s) == Darwin && $(uname -m) == amd64 ]] -then - platform='Darwin_amd64' -elif [[ $(uname -s) == Darwin && $(uname -m) == arm64 ]] -then - platform='darwin_arm64' -elif [[ $(uname -s) == Linux ]] -then - platform='linux_amd64' -else - echo "No supported architecture found" - exit 1 +platform=$(uname -s | tr '[:upper:]' '[:lower:]') +arch=$(uname -m | tr '[:upper:]' '[:lower:]') + +# We direct goreleaser to convert "amd64" to "x86_64", so perform the same rename +# here if necessary +if [[ $arch == "amd64" ]] +then + arch="x86_64" fi get_release_url () { -jq_cmd=".assets[] | select(.name | endswith(\"${platform}.tar.gz\")).browser_download_url" +jq_cmd=".assets[] | select(.name | endswith(\"${platform}-${arch}.tar.gz\")).browser_download_url" # Find the latest binary release URL for this platform url="$(curl -sL https://api.github.com/repos/zackproser/procrastiproxy/releases/latest | jq -r "${jq_cmd}")" echo $url @@ -27,12 +23,14 @@ target_url="$(get_release_url)" curl -LO $target_url #Rename and copy to your procrastiproxy folder filename=$(basename $target_url) -tar xvzf ${filename} -filename="procrastiproxy" -chmod +x ${filename} +tar xvzf "${filename}" +binaryname="procrastiproxy" +unzippeddir="${filename/.tar.gz/""}" +fullpath="${unzippeddir}/${binaryname}" +chmod +x "${fullpath}" PROCRASTIPROXY_DIR=/usr/local/bin/procrastiproxy -sudo mv $filename ${PROCRASTIPROXY_DIR} +sudo mv "${fullpath}" "${PROCRASTIPROXY_DIR}" if [[ $? -eq 0 ]]; then echo "Successfully installed $binary_name at $PROCRASTIPROXY_DIR" else