Skip to content

Commit

Permalink
Merge pull request #13 from DeNetPRO/upd/install.sh
Browse files Browse the repository at this point in the history
Update install.sh
  • Loading branch information
OxFEE1DEAD authored Jul 18, 2024
2 parents 5f97e2e + dfae346 commit 520eac4
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
#!/bin/bash
#

set -euo pipefail
# allow specifying different destination directory
DIR="${DIR:-"$HOME/.local/bin"}"

# map different architecture variations to the available binaries
ARCH=$(uname | tr [:upper:] [:lower:])
RELEASE="${1:-"latest"}"

# prepare the download URL
GITHUB_LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' https://github.com/denetpro/node/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
GITHUB_FILE="denode-$ARCH.zip"
GITHUB_URL="https://github.com/denetpro/node/releases/download/${GITHUB_LATEST_VERSION}/${GITHUB_FILE}"
TAG=$(curl -L -s -H 'Accept: application/json' https://github.com/denetpro/node/releases/$RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')

ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) error "Unsupported architecture: $ARCH" ;;
esac


GITHUB_FILE=$(echo "denode-$(uname -s)-$ARCH" | tr '[:upper:]' '[:lower:]')
GITHUB_URL="https://github.com/denetpro/node/releases/download/${TAG}/${GITHUB_FILE}"

# install/update the local binary
curl -L -o denode.zip $GITHUB_URL
unzip -a denode.zip && rm -rf denode.zip
mkdir -p $DIR
curl -L -o denode $GITHUB_URL --fail
install -m 555 denode -t "$DIR"
rm -f denode
echo "`denode -v` successfully installed"

0 comments on commit 520eac4

Please sign in to comment.