Skip to content

Commit b9511ad

Browse files
authored
Update install CLI script (#50)
* Update install script to work with goreleaser * Update install-cli version to 0.1.0-beta.1 * Update CLI readme
1 parent 16502dc commit b9511ad

File tree

2 files changed

+35
-49
lines changed

2 files changed

+35
-49
lines changed

cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This is a CLI tool for installing and managing the The Observability Stack for K
66

77
__Dependencies__: [Go](https://golang.org/doc/install), [Helm](https://helm.sh/docs/intro/install/)
88

9-
To install the CLI, run `go install` from inside the `tobs` folder.
10-
Then, copy the `tobs` binary from `$GOPATH/bin` to your `/bin` folder.
9+
To build from source, run `go build -o tobs` from inside the `cli` folder.
10+
Then, move the `tobs` binary from the current directory to your `/bin` folder.
1111

1212
## Commands
1313

install-cli.sh

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,102 @@
22

33
set -eu
44

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}
77

88
happyexit() {
99
echo ""
10-
echo "Add the ts-obs CLI to your path with:"
10+
echo "Add the tobs CLI to your path with:"
1111
echo ""
1212
echo " export PATH=\$PATH:${INSTALLROOT}/bin"
1313
echo ""
1414
echo "After starting your cluster, run"
1515
echo ""
16-
echo " ts-obs install"
16+
echo " tobs install"
1717
echo ""
1818
exit 0
1919
}
2020

2121
validate_checksum() {
2222
filename=$1
23-
SHA=$(curl -sfL "${url}.sha256")
23+
checksumlist=$(curl -sfL "${url}/checksums.txt")
2424
echo ""
2525
echo "Validating checksum..."
2626

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}")
3528

36-
if [ "$checksum" != "$SHA" ]; then
29+
if grep -Fxq "${checksum}" <<< "${checksumlist}"; then
30+
echo "Checksum valid."
31+
return 0
32+
else
3733
echo "Checksum validation failed." >&2
3834
return 1
3935
fi
40-
echo "Checksum valid."
41-
return 0
4236
}
4337

4438
OS=$(uname -s)
4539
arch=$(uname -m)
4640
case $OS in
47-
CYGWIN* | MINGW64*)
48-
OS=windows.exe
49-
;;
5041
Darwin)
5142
;;
5243
Linux)
5344
case $arch in
5445
x86_64)
5546
;;
47+
i386)
48+
;;
5649
*)
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."
5851
exit 1
5952
;;
6053
esac
6154
;;
6255
*)
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."
6457
exit 1
6558
;;
6659
esac
67-
OS=$(echo $OS | tr '[:upper:]' '[:lower:]')
6860

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."
7163
exit 1
7264
}
7365

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}"
9275

9376
(
9477
cd "$tmpdir"
9578

9679
echo "Downloading ${srcfile}..."
97-
curl -fLO "${url}"
80+
curl -fLO "${url}/${srcfile}"
9881
echo "Download complete!"
9982

10083
if ! validate_checksum "${srcfile}"; then
10184
exit 1
10285
fi
86+
87+
$tarbin -xvf $srcfile
88+
10389
echo ""
10490
)
10591

10692
(
10793
mkdir -p "${INSTALLROOT}/bin"
108-
mv "${tmpdir}/${srcfile}" "${dstfile}"
94+
mv "${tmpdir}/tobs" "${dstfile}"
10995
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"
11298
)
11399

114100
rm -r "$tmpdir"
115-
echo "ts-obs ${TS_OBS_VERSION} was successfully installed 🎉"
101+
echo "tobs ${TOBS_VERSION} was successfully installed 🎉"
116102
echo ""
117103
happyexit

0 commit comments

Comments
 (0)