forked from theketchio/ketch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
70 lines (57 loc) · 1.73 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
RELEASE_DOWNLOAD_URL="https://github.com/theketchio/ketch/releases"
: "${INSTALL_DIR:="/usr/local/bin"}"
# Get Ketch tag requested by the user from ENV variable
hasUserProvidedTAG() {
[[ -n "$TAG" ]]
}
getPlatform() {
set -eu
UNAME=$(uname)
if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ]; then
echo "Sorry, OS not supported: ${UNAME}. Download binary from ${RELEASE_DOWNLOAD_URL}"
exit 1
fi
case "${UNAME}" in
Darwin)
OSX_ARCH=$(uname -m)
if [ "${OSX_ARCH}" = "x86_64" ] || [ "${OSX_ARCH}" = "arm64" ]; then
PLATFORM="darwin-amd64"
else
echo "Sorry, architecture not supported: ${OSX_ARCH}. Download binary from ${RELEASE_DOWNLOAD_URL}"
exit 1
fi
;;
Linux)
LINUX_ARCH=$(uname -m)
if [ "${LINUX_ARCH}" = "x86_64" ]; then
PLATFORM="linux-amd64"
else
echo "Sorry, architecture not supported: ${LINUX_ARCH}. Download binary from ${RELEASE_DOWNLOAD_URL}"
exit 1
fi
;;
esac
}
getLatestTag() {
TAG=$(curl -s https://api.github.com/repos/theketchio/ketch/releases/latest | grep -Eo '"tag_name":.*[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
}
install() {
DOWNLOAD_URL="${RELEASE_DOWNLOAD_URL}/download/$TAG/ketch-$PLATFORM"
DEST=${DEST:-${INSTALL_DIR}/ketch}
if [ -z "$TAG" ]; then
echo "Error requesting. Download binary from ${RELEASE_DOWNLOAD_URL}"
exit 1
else
echo "Downloading Ketch binary from ${DOWNLOAD_URL} to $DEST"
if curl -sL "${DOWNLOAD_URL}" -o "$DEST"; then
chmod +x "$DEST"
echo "Ketch client installation was successful"
else
echo "Installation failed. You may need elevated permissions."
fi
fi
}
hasUserProvidedTAG || getLatestTag
getPlatform
install