Skip to content

Commit

Permalink
Simplify install.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
zackproser committed May 2, 2022
1 parent c0f3065 commit e5d74ac
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e5d74ac

Please sign in to comment.