forked from anoma/namada-trusted-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·69 lines (59 loc) · 2.89 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
#!/bin/sh
# shellcheck shell=dash
# # This is just a little script that can be downloaded from the internet to
# install Namada Trusted Setup bianries. It just does platform detection,
# downloads and install the correct binaries.
set -u
LAST_BINARY_VERSION="1.0.0-beta.8"
BINARY_NAME="namada-ts"
BINARY_FOLDER="$HOME/.namada-ts"
BINARY_PATH="$BINARY_FOLDER/$BINARY_NAME"
OS_TYPE=$(uname -s)
ARCHITECTURE=$(uname -m)
BINARY_EXIST_CHECK=$(command -v $BINARY_NAME &>/dev/null)
BINARY_EXIST_CHECK_EXIT_CODE=$?
USER_ID=`id -u`
if [ $USER_ID -eq 0 ]; then
echo "Do not with as sudo."
exit 1
fi
if [ $BINARY_EXIST_CHECK_EXIT_CODE -eq 0 ]; then
CURRENT_BINARY_VERSION_CHECK=$($BINARY_NAME --version)
if [[ "$BINARY_NAME $LAST_BINARY_VERSION" == "$CURRENT_BINARY_VERSION_CHECK" ]]; then
echo "Your binaries are up to date!"
else
echo "Removing old binary..."
rm $BINARY_PATH
echo "Downloading newer binary for ${OS_TYPE}/${ARCHITECTURE}..."
if [[ "$OS_TYPE" == "Darwin" && "$ARCHITECTURE" == "x86_64" ]]; then
curl -s https://github.com/anoma/namada-trusted-setup/releases/download/v${LAST_BINARY_VERSION}/${BINARY_NAME}-macos-v${LAST_BINARY_VERSION} -L -o $BINARY_PATH
elif [[ "$OS_TYPE" == "Linux" && "$ARCHITECTURE" == "x86_64" ]]; then
curl -s https://github.com/anoma/namada-trusted-setup/releases/download/v${LAST_BINARY_VERSION}/${BINARY_NAME}-linux-v${LAST_BINARY_VERSION} -L -o $BINARY_PATH
else
echo "No binary for ${OS_TYPE}/${ARCHITECTURE}."
echo "You should clone the repository and build from source."
exit 1
fi
echo "Done dowloading binary in $BINARY_PATH."
echo "Your should export the binary to \$PATH by running:"
echo " export PATH=\$PATH:~/.namada-ts"
chmod +x $BINARY_PATH
fi
else
echo "Creating binary folder..."
mkdir -p $BINARY_FOLDER
echo "Downloading new binary for ${OS_TYPE}/${ARCHITECTURE}..."
if [[ "$OS_TYPE" == "Darwin" && "$ARCHITECTURE" == "x86_64" ]]; then
curl -s https://github.com/anoma/namada-trusted-setup/releases/download/v${LAST_BINARY_VERSION}/${BINARY_NAME}-macos-v${LAST_BINARY_VERSION} -L -o $BINARY_PATH
elif [[ "$OS_TYPE" == "Linux" && "$ARCHITECTURE" == "x86_64" ]]; then
curl -s https://github.com/anoma/namada-trusted-setup/releases/download/v${LAST_BINARY_VERSION}/${BINARY_NAME}-linux-v${LAST_BINARY_VERSION} -L -o $BINARY_PATH
else
echo "No binary for ${OS_TYPE}/${ARCHITECTURE}."
echo "You should clone the repository and build from source. Check the docs here: https://github.com/anoma/namada-trusted-setup#building-and-contributing-from-source."
exit 1
fi
chmod +x $BINARY_PATH
echo "Done dowloading binary in $BINARY_PATH."
echo "Your should export the binary to \$PATH by running:"
echo " export PATH=\$PATH:~/.namada-ts"
fi