forked from arriven/db1000n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·38 lines (30 loc) · 1.15 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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}