forked from anoma/anoma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_tendermint.sh
executable file
·48 lines (35 loc) · 1.27 KB
/
get_tendermint.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
#!/usr/bin/env bash
set -Eo pipefail
# an examplary download-url
# https://github.com/tendermint/tendermint/releases/download/v0.34.13/tendermint_0.34.13_linux_amd64.tar.gz
TM_MAJORMINOR="0.34"
TM_PATCH="13"
TM_REPO="https://github.com/tendermint/tendermint"
TM_VERSION="${TM_MAJORMINOR}.${TM_PATCH}"
TARGET_PATH="/usr/local/bin"
TMP_PATH="/tmp"
error_exit()
{
echo "Error: $1" >&2
exit 1
}
# check for existence
TM_EXECUTABLE=$(which tendermint)
if [ -x "$TM_EXECUTABLE" ]; then
TM_EXISTS_VER=$(${TM_EXECUTABLE} version)
fi
if [[ $TM_EXISTS_VER == "${TM_MAJORMINOR}" ]]; then
echo "tendermint already exists in your current PATH with a sufficient version = $TM_EXISTS_VER"
echo "tendermint is located at = $(which tendermint)"
exit
fi
read -r SYSTEM MACHINE <<< "$(uname -s -m)"
ARCH="amd64"
if [[ $MACHINE = "aarch64" ]] || [[ $MACHINE = "arm64" ]]; then
ARCH="arm64"
fi
RELEASE_URL="${TM_REPO}/releases/download/v${TM_VERSION}/tendermint_${TM_VERSION}_$(echo "${SYSTEM}" | tr '[:upper:]' '[:lower:]')_${ARCH}.tar.gz"
echo "$RELEASE_URL"
curl -LsSfo "$TMP_PATH"/tendermint.tar.gz "$RELEASE_URL" || error_exit "tendermint release download failed"
cd $TARGET_PATH
sudo tar -xvzf $TMP_PATH/tendermint.tar.gz tendermint || error_exit "tendermint release extraction failed"