|
2 | 2 |
|
3 | 3 | set -eu |
4 | 4 |
|
5 | | -INSTALLROOT=${INSTALLROOT:-"${HOME}/.ts-obs"} |
6 | | -TS_OBS_VERSION=${TS_OBS_VERSION:-0.1.0-alpha.4.1} |
| 5 | +INSTALLROOT=${INSTALLROOT:-"${HOME}/.tobs"} |
| 6 | +TOBS_VERSION=${TOBS_VERSION:-0.1.0-beta.1} |
7 | 7 |
|
8 | 8 | happyexit() { |
9 | 9 | echo "" |
10 | | - echo "Add the ts-obs CLI to your path with:" |
| 10 | + echo "Add the tobs CLI to your path with:" |
11 | 11 | echo "" |
12 | 12 | echo " export PATH=\$PATH:${INSTALLROOT}/bin" |
13 | 13 | echo "" |
14 | 14 | echo "After starting your cluster, run" |
15 | 15 | echo "" |
16 | | - echo " ts-obs install" |
| 16 | + echo " tobs install" |
17 | 17 | echo "" |
18 | 18 | exit 0 |
19 | 19 | } |
20 | 20 |
|
21 | 21 | validate_checksum() { |
22 | 22 | filename=$1 |
23 | | - SHA=$(curl -sfL "${url}.sha256") |
| 23 | + checksumlist=$(curl -sfL "${url}/checksums.txt") |
24 | 24 | echo "" |
25 | 25 | echo "Validating checksum..." |
26 | 26 |
|
27 | | - case $checksumbin in |
28 | | - *openssl) |
29 | | - checksum=$($checksumbin dgst -sha256 "${filename}" | sed -e 's/^.* //') |
30 | | - ;; |
31 | | - *shasum) |
32 | | - checksum=$($checksumbin -a256 "${filename}" | sed -e 's/^.* //') |
33 | | - ;; |
34 | | - esac |
| 27 | + checksum=$($checksumbin -a256 "${filename}") |
35 | 28 |
|
36 | | - if [ "$checksum" != "$SHA" ]; then |
| 29 | + if grep -Fxq "${checksum}" <<< "${checksumlist}"; then |
| 30 | + echo "Checksum valid." |
| 31 | + return 0 |
| 32 | + else |
37 | 33 | echo "Checksum validation failed." >&2 |
38 | 34 | return 1 |
39 | 35 | fi |
40 | | - echo "Checksum valid." |
41 | | - return 0 |
42 | 36 | } |
43 | 37 |
|
44 | 38 | OS=$(uname -s) |
45 | 39 | arch=$(uname -m) |
46 | 40 | case $OS in |
47 | | - CYGWIN* | MINGW64*) |
48 | | - OS=windows.exe |
49 | | - ;; |
50 | 41 | Darwin) |
51 | 42 | ;; |
52 | 43 | Linux) |
53 | 44 | case $arch in |
54 | 45 | x86_64) |
55 | 46 | ;; |
| 47 | + i386) |
| 48 | + ;; |
56 | 49 | *) |
57 | | - echo "Timescale Observability does not support $OS/$arch. Please open an issue with your platform details." |
| 50 | + echo "The Observability Stack does not support $OS/$arch. Please open an issue with your platform details." |
58 | 51 | exit 1 |
59 | 52 | ;; |
60 | 53 | esac |
61 | 54 | ;; |
62 | 55 | *) |
63 | | - echo "Timescale Observability does not support $OS/$arch. Please open an issue with your platform details." |
| 56 | + echo "The Observability Stack does not support $OS/$arch. Please open an issue with your platform details." |
64 | 57 | exit 1 |
65 | 58 | ;; |
66 | 59 | esac |
67 | | -OS=$(echo $OS | tr '[:upper:]' '[:lower:]') |
68 | 60 |
|
69 | | -checksumbin=$(command -v openssl) || checksumbin=$(command -v shasum) || { |
70 | | - echo "Failed to find checksum binary. Please install openssl or shasum." |
| 61 | +tarbin=$(command -v tar) || { |
| 62 | + echo "Failed to find unpacking binary. Please install tar." |
71 | 63 | exit 1 |
72 | 64 | } |
73 | 65 |
|
74 | | -tmpdir=$(mktemp -d /tmp/ts-obs.XXXXXX) |
75 | | -srcfile="ts-obs-${TS_OBS_VERSION}-${OS}" |
76 | | -dstfile="${INSTALLROOT}/bin/ts-obs-${TS_OBS_VERSION}" |
77 | | -url="https://github.com/timescale/timescale-observability/releases/download/${TS_OBS_VERSION}/${srcfile}" |
78 | | - |
79 | | -if [ -e "${dstfile}" ]; then |
80 | | - if validate_checksum "${dstfile}"; then |
81 | | - echo "" |
82 | | - echo "ts-obs ${TS_OBS_VERSION} was already downloaded; making it the default" |
83 | | - echo "" |
84 | | - echo "To force re-downloading, delete '${dstfile}' then run me again." |
85 | | - ( |
86 | | - rm -f "${INSTALLROOT}/bin/ts-obs" |
87 | | - ln -s "${dstfile}" "${INSTALLROOT}/bin/ts-obs" |
88 | | - ) |
89 | | - happyexit |
90 | | - fi |
91 | | -fi |
| 66 | +checksumbin=$(command -v shasum) || { |
| 67 | + echo "Failed to find checksum binary. Please install shasum." |
| 68 | + exit 1 |
| 69 | +} |
| 70 | + |
| 71 | +tmpdir=$(mktemp -d /tmp/tobs.XXXXXX) |
| 72 | +srcfile="tobs_${TOBS_VERSION}_${OS}_${arch}.tar.gz" |
| 73 | +dstfile="${INSTALLROOT}/bin/tobs-${TOBS_VERSION}" |
| 74 | +url="https://github.com/timescale/timescale-observability/releases/download/${TOBS_VERSION}" |
92 | 75 |
|
93 | 76 | ( |
94 | 77 | cd "$tmpdir" |
95 | 78 |
|
96 | 79 | echo "Downloading ${srcfile}..." |
97 | | - curl -fLO "${url}" |
| 80 | + curl -fLO "${url}/${srcfile}" |
98 | 81 | echo "Download complete!" |
99 | 82 |
|
100 | 83 | if ! validate_checksum "${srcfile}"; then |
101 | 84 | exit 1 |
102 | 85 | fi |
| 86 | + |
| 87 | + $tarbin -xvf $srcfile |
| 88 | + |
103 | 89 | echo "" |
104 | 90 | ) |
105 | 91 |
|
106 | 92 | ( |
107 | 93 | mkdir -p "${INSTALLROOT}/bin" |
108 | | - mv "${tmpdir}/${srcfile}" "${dstfile}" |
| 94 | + mv "${tmpdir}/tobs" "${dstfile}" |
109 | 95 | chmod +x "${dstfile}" |
110 | | - rm -f "${INSTALLROOT}/bin/ts-obs" |
111 | | - ln -s "${dstfile}" "${INSTALLROOT}/bin/ts-obs" |
| 96 | + rm -f "${INSTALLROOT}/bin/tobs" |
| 97 | + ln -s "${dstfile}" "${INSTALLROOT}/bin/tobs" |
112 | 98 | ) |
113 | 99 |
|
114 | 100 | rm -r "$tmpdir" |
115 | | -echo "ts-obs ${TS_OBS_VERSION} was successfully installed 🎉" |
| 101 | +echo "tobs ${TOBS_VERSION} was successfully installed 🎉" |
116 | 102 | echo "" |
117 | 103 | happyexit |
0 commit comments