Skip to content

Commit

Permalink
Install script
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Feb 28, 2022
1 parent b10b6b4 commit cc59d13
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
REPO="Arriven/db1000n"
INSTALL_OS="unknown"
case "$OSTYPE" in
solaris*) INSTALL_OS="solaris" ;;
darwin*) INSTALL_OS="darwin" ;;
linux*) INSTALL_OS="linux" ;;
bsd*) INSTALL_OS="bsd" ;;
msys*) INSTALL_OS="windows" ;;
cygwin*) INSTALL_OS="windows" ;;
*) echo "unknown: $OSTYPE"; exit 1 ;;
esac

INSTALL_ARCH="unknown"
OSARCH=$(uname -m)
case "$OSARCH" in
x86_64*) INSTALL_ARCH="amd64" ;;
i386*) INSTALL_ARCH="386" ;;
arm*) INSTALL_ARCH="arm" ;;
*) echo "unknown: $OSARCH"; exit 1 ;;
esac

INSTALL_VERSION="${INSTALL_OS}-${INSTALL_ARCH}"

curl https://api.github.com/repos/${REPO}/releases/latest | grep "${INSTALL_VERSION}" | grep -Eo 'https://[^\"]*' | xargs wget

INSTALL_TAG=$(curl --silent "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

ARCHIVE="db1000n-${INSTALL_TAG}-${INSTALL_VERSION}.tar.gz"

cat ${ARCHIVE} | md5sum | awk '{ print $1 }' > md5sum.txt

if ! cmp --silent "${ARCHIVE}.md5" "md5sum.txt"; then
echo "md5sum for ${ARCHIVE} failed. Please check the md5sum. File may possibly be corrupted."
exit 1
fi

tar xvf ${ARCHIVE}

0 comments on commit cc59d13

Please sign in to comment.