forked from timescale/tobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-cli.sh
executable file
·102 lines (87 loc) · 2.19 KB
/
install-cli.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
set -eu
INSTALLROOT=${INSTALLROOT:-"${HOME}/.tobs"}
TOBS_VERSION=${TOBS_VERSION:-0.1.0}
happyexit() {
echo ""
echo "Add the tobs CLI to your system binaries with:"
echo ""
echo " sudo cp ${INSTALLROOT}/bin/tobs /usr/local/bin"
echo ""
echo "Alternatively, add tobs to your path in the current session with: export PATH=\$PATH:${INSTALLROOT}/bin"
echo ""
echo "After starting your Kubernetes cluster, run"
echo ""
echo " tobs install"
echo ""
exit 0
}
validate_checksum() {
filename=$1
checksumlist=$(curl -sfL "${url}/checksums.txt")
echo ""
echo "Validating checksum..."
checksum=$($checksumbin -a256 "${filename}")
if grep -Fxq "${checksum}" <<< "${checksumlist}"; then
echo "Checksum valid."
return 0
else
echo "Checksum validation failed." >&2
return 1
fi
}
install_tobs () {
OS=$(uname -s)
arch=$(uname -m)
case $OS in
Darwin)
;;
Linux)
case $arch in
x86_64)
;;
i386)
;;
*)
echo "The Observability Stack does not support $OS/$arch. Please open an issue with your platform details."
exit 1
;;
esac
;;
*)
echo "The Observability Stack does not support $OS/$arch. Please open an issue with your platform details."
exit 1
;;
esac
checksumbin=$(command -v shasum) || {
echo "Failed to find checksum binary. Please install shasum."
exit 1
}
tmpdir=$(mktemp -d /tmp/tobs.XXXXXX)
srcfile="tobs_${TOBS_VERSION}_${OS}_${arch}"
dstfile="${INSTALLROOT}/bin/tobs-${TOBS_VERSION}"
url="https://github.com/timescale/tobs/releases/download/${TOBS_VERSION}"
(
cd "$tmpdir"
echo "\n"
echo "Downloading ${srcfile}..."
curl --proto '=https' --tlsv1.2 -sSfLO "${url}/${srcfile}"
echo "Download complete!"
if ! validate_checksum "${srcfile}"; then
exit 1
fi
echo ""
)
(
mkdir -p "${INSTALLROOT}/bin"
mv "${tmpdir}/${srcfile}" "${dstfile}"
chmod +x "${dstfile}"
rm -f "${INSTALLROOT}/bin/tobs"
ln -s "${dstfile}" "${INSTALLROOT}/bin/tobs"
)
rm -r "$tmpdir"
echo "tobs ${TOBS_VERSION} was successfully installed 🎉"
echo ""
happyexit
}
install_tobs