From cc59d13b1af0134e32416b3a02f81a757572b87a Mon Sep 17 00:00:00 2001 From: bivashko-cyberhaven Date: Mon, 28 Feb 2022 09:51:58 +0200 Subject: [PATCH] Install script --- install.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..ff1b4f2a --- /dev/null +++ b/install.sh @@ -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} \ No newline at end of file