This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
install.sh
209 lines (183 loc) · 7.84 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# Install script for Binance Chain
# - CLI (bnbcli)
# - Full Node client (bnbchaind)
# - Light Node client (lightd)
# - Installs both testnet and prod
# Note: this is based on current structure of `node-binary` repo, which is not optimal
# - The installer script is a hack to simplify the installation process
# - Our binaries should eventually be refactor into a `apt` or `npm` repo, which features upgradability
# - We should not rely on folders for addressing (instead use git branches for versions)
# Detect operating system
# Future Improvement: Refactor into helper function
if [[ "$OSTYPE" == "linux-gnu" ]]; then
DETECTED_OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
DETECTED_OS="mac"
elif [[ "$OSTYPE" == "cygwin" ]]; then
DETECTED_OS="linux"
elif [[ "$OSTYPE" == "msys" ]]; then
DETECTED_OS="windows"
elif [[ "$OSTYPE" == "win32" ]]; then
DETECTED_OS="windows" # TODO(Dan): can you run shell on windows?
elif [[ "$OSTYPE" == "freebsd"* ]]; then
DETECTED_OS="linux"
else
FULLNODE_echo "Error: unable to detect operating system. Please install manually by referring to $DOCS_WEB_LINK"
LIGHTNODE_DOCS_WEB_LINK=""
exit 1
fi
# Check for existence of wget
if [ ! -x /usr/bin/wget ]; then
# some extra check if wget is not installed at the usual place
command -v wget >/dev/null 2>&1 || {
echo >&2 "Error: you need to have wget installed and in your path. Use brew (mac) or apt (unix) to install wget"
exit 1
}
fi
echo "@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@"
echo "@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@"
echo "@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@"
echo "@@@@@@@@@@@@@ @@@@@@@@@@@@@"
echo "@@@@@@@@@@@ @@@@@@@@@@@"
echo "@@@@@@@@@ @@@ @@@@@@@@@"
echo "@@@@@@@@ @@@@@@@ @@@@@@@@"
echo "@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@"
echo "@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@"
echo "@ @@@@@@@@ @@@@@@@@ @"
echo "@ @@@@@@@@ @@@@@@@@ @"
echo "@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@"
echo "@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@"
echo "@@@@@@@@ @@@@@@@ @@@@@@@@"
echo "@@@@@@@@@ @@@ @@@@@@@@@"
echo "@@@@@@@@@@@ @@@@@@@@@@@"
echo "@@@@@@@@@@@@@ @@@@@@@@@@@@@"
echo "@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@"
echo "@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@"
echo ""
echo "========== Binance Chain Node Installation =========="
echo "Installer Version: 0.1.beta"
echo "Detected OS: $DETECTED_OS"
echo "====================================================="
# Links to Documentation
FULLNODE_DOCS_WEB_LINK="https://docs.binance.org/fullnode.html"
LIGHTNODE_DOCS_WEB_LINK="https://docs.binance.org/light-client.html"
# Install location
USR_LOCAL_BIN="/usr/local/bin"
# Note: /usr/local/bin choice from https://unix.stackexchange.com/questions/259231/difference-between-usr-bin-and-usr-local-bin
# Future improvement: needs uninstall script (brew uninstall) that removes executable from bin
# Choose Full Node Directory
read -e -p "Choose home directory for Full Node [default: ~/.bnbchaind]:" BNC_FULLNODE_DIR
BNC_FULLNODE_DIR=${BNC_FULLNODE_DIR:-"$HOME/.bnbchaind"}
# Choose BNBCLI directory
read -e -p "Choose home directory for CLI [default: ~/.bnbcli]:" BNC_CLI_DIR
BNC_CLI_DIR=${BNC_CLI_DIR:-"$HOME/.bnbcli"}
# Choose Light Node directory
read -e -p "Choose home directory for Light Node [default: ~/.binance-lite]:" BNC_LIGHTNODE_DIR
BNC_LIGHTNODE_DIR=${BNC_LIGHTNODE_DIR:-"$HOME/.binance-lite"}
# Detect previous installation and create .bnbchaind folder,
BNC_FULLNODE_CONFIG_DIR="$BNC_FULLNODE_DIR/config"
echo "... creating $BNC_FULLNODE_DIR"
if [ -d "$BNC_FULLNODE_DIR" ]; then
echo "... Error: Binance Chain Fullnode has already been installed"
echo "... Error: Please remove contents of ${BNC_FULLNODE_DIR} before reinstalling."
exit 1
else
mkdir -p $BNC_FULLNODE_CONFIG_DIR
cd $BNC_FULLNODE_DIR
fi
if [ -f "$USR_LOCAL_BIN/bnbchaind" ]; then
echo "... Error: Binance Chain Fullnode has already been installed"
echo "... Error: Please remove bnbchaind from /usr/local/bin before reinstalling."
exit 1
fi
if [ -f "$USR_LOCAL_BIN/lightd" ]; then
echo "... Error: Binance Chain Light Node has already been installed"
echo "... Error: Please remove lightd from /usr/local/bin before reinstalling."
exit 1
fi
if [ -f "$USR_LOCAL_BIN/bnbcli" ]; then
echo "... Error: Binance Chain CLI Mainnet has already been installed"
echo "... Error: Please remove bnbcli from /usr/local/bin before reinstalling."
exit 1
fi
if [ -f "$USR_LOCAL_BIN/tbnbcli" ]; then
echo "... Error: Binance Chain CLI Testnet has already been installed"
echo "... Error: Please remove tbnbcli from /usr/local/bin before reinstalling."
exit 1
fi
# Version selection options
# Future improvement: pull dynamically from version list
CLI_LATEST_VERSION="0.8.2"
TEST_CLI_LATEST_VERSION="0.8.1"
# CLI_PROD_VERSION_NUMBERS=("0.5.8" "0.5.8.1" "0.6.0" "0.6.1" "0.6.2" "0.6.2-TSS-0.1.2" "0.6.3")
# CLI_TESTNET_VERSION_NUMBERS=("0.5.8" "0.5.8.1" "0.6.0" "0.6.1" "0.6.2" "0.6.2-TSS-0.1.2" "0.6.3")
#FULLNODE_LATEST_VERSION="0.6.3-hotfix-2"
# FULLNODE_PROD_VERSION_NUMBERS=("0.5.8" "0.5.9" "0.5.10" "0.6.0" "0.6.1" "0.6.2" "0.6.3" "0.6.3-hotfix")
# FULLNODE_TESTNET_VERSION_NUMBERS=("0.5.8" "0.5.10" "0.6.0" "0.6.1" "0.6.1-hotfix" "0.6.2" "0.6.3" "0.6.3-hotfix")
LIGHTNODE_LATEST_VERSION="0.6.3"
# LIGHTNODE_PROD_VERSION_NUMBERS=("0.5.8" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
# LIGHTNODE_TESTNET_VERSION_NUMBERS=("0.5.8" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
# File Download URLs
GH_REPO_URL="https://github.com/binance-chain/node-binary/raw/master"
# Download both Testnet and Mainnet CLI
for NETWORK in "prod" "testnet"; do
if [ "$NETWORK" = "prod" ]; then
FILENAME="bnbcli"
CLI_VERSION_PATH="cli/$NETWORK/$CLI_LATEST_VERSION/$DETECTED_OS/$FILENAME"
CLI_BINARY_URL="$GH_REPO_URL/$CLI_VERSION_PATH"
cd $USR_LOCAL_BIN
echo "... Downloading $FILENAME executable version:" $CLI_LATEST_VERSION
wget -q --show-progress "$CLI_BINARY_URL"
chmod 755 "./$FILENAME"
else
FILENAME="tbnbcli"
CLI_VERSION_PATH="cli/$NETWORK/$TEST_CLI_LATEST_VERSION/$DETECTED_OS/$FILENAME"
CLI_BINARY_URL="$GH_REPO_URL/$CLI_VERSION_PATH"
cd $USR_LOCAL_BIN
echo "... Downloading $FILENAME executable version:" $TEST_CLI_LATEST_VERSION
wget -q --show-progress "$CLI_BINARY_URL"
chmod 755 "./$FILENAME"
fi
done
# Download Light Node
LIGHTNODE_VERSION_PATH="lightnode/prod/$LIGHTNODE_LATEST_VERSION/$DETECTED_OS"
LIGHTNODE_BINARY_URL="$GH_REPO_URL/$LIGHTNODE_VERSION_PATH/lightd"
cd $USR_LOCAL_BIN
echo "... Downloading lightd executable version:" $LIGHTNODE_LATEST_VERSION
wget -q --show-progress "$LIGHTNODE_BINARY_URL"
chmod 755 "./lightd"
# Download Full Node
echo "... Choose node type to install"
echo "... Choose Network Version"
OPTION_NETWORK=("Mainnet" "Testnet")
PS3='Choose Network Type: '
select opt in "${OPTION_NETWORK[@]}"; do
case $opt in
"Mainnet")
FULLNODE_LATEST_VERSION="0.8.2"
FULLNODE_VERSION_PATH="fullnode/prod/$FULLNODE_LATEST_VERSION"
break
;;
"Testnet")
FULLNODE_LATEST_VERSION="0.8.1"
FULLNODE_VERSION_PATH="fullnode/testnet/$FULLNODE_LATEST_VERSION"
break
;;
esac
done
FULLNODE_CONFIG_URL="$GH_REPO_URL/$FULLNODE_VERSION_PATH/config"
FULLNODE_BINARY_URL="$GH_REPO_URL/$FULLNODE_VERSION_PATH/$DETECTED_OS/bnbchaind"
cd $BNC_FULLNODE_CONFIG_DIR
echo "... Downloading config files for full node"
wget -q --show-progress "$FULLNODE_CONFIG_URL/app.toml"
wget -q --show-progress "$FULLNODE_CONFIG_URL/config.toml"
wget -q --show-progress "$FULLNODE_CONFIG_URL/genesis.json"
cd $USR_LOCAL_BIN
echo "... Downloading bnbchaind executable version:" $FULLNODE_LATEST_VERSION
wget -q --show-progress "$FULLNODE_BINARY_URL"
chmod 755 "./bnbchaind"
# exit 1
# Add installed version of Binance Chain to path
echo "... Installation successful!"
echo "... \`bnbcli\`, \`tbnbcli\`, \`bnbchaind\`, \`lightd\` added to $USR_LOCAL_BIN"