Skip to content

Commit 7deb126

Browse files
Update Installer Script to install all executables (bnb-chain#196)
* Initial commit of documentation * change git lfs track * add git lfs tracks * add git lfs tracks * update git lfs track * Add initial scaffold of install script * Add OS detection, prompts for which version to install * Update install script * Installation script for full node completed * Add lightd install script * Finish scaffold of README * Change command to run interactive prompt * Update install.sh * Update README.md * Update install.sh * Update install.sh * Rephrase home directory * Merge upstream * Update installer script to install latest version of all binaries * add binary version info Co-authored-by: huangsuyu <[email protected]>
1 parent 41b6897 commit 7deb126

File tree

2 files changed

+125
-117
lines changed

2 files changed

+125
-117
lines changed

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Binance Chain Client
22

3-
[Binance Chain](https://www.binance.org/) is a blockchain developed by Binance and its community, that focuses on building a performant matching engine and exchange over a decentralized network.
3+
[Binance Chain](https://www.binance.org/) is a blockchain developed by Binance and its community, that focuses on building a performant matching engine and exchange over a decentralized network.
44

5-
* [Match logic](https://docs.binance.org/match.html)
6-
* [Anti-front running](https://docs.binance.org/anti-frontrun.html)
5+
- [Match logic](https://docs.binance.org/match.html)
6+
- [Anti-front running](https://docs.binance.org/anti-frontrun.html)
77

88
Binance Chain clients are released as compiled executables in this repo, with a few variants:
99

10-
* [Full Node](https://docs.binance.org/fullnode.html): downloads full blockchain and relays transactions
11-
* [Light Client](https://docs.binance.org/light-client.html): does not sync state or relay transactions
10+
- [Full Node](https://docs.binance.org/fullnode.html): downloads full blockchain and relays transactions
11+
- [Light Client](https://docs.binance.org/light-client.html): does not sync state or relay transactions
1212

1313
For more on which client to run, see [Light Client vs Full Node](https://docs.binance.org/light-client.html#light-client-versus-full-node).
1414

1515
## Installation Script
1616

1717
We have a community-maintained installer script (`install.sh`) that takes care of chain directory setup. This uses the following defaults:
1818

19-
* Home folder in `~/.bnbchaind`
20-
* Client executables stored in `/usr/local/bin` (i.e. `light` or `bnbchaind`)
19+
- Home folder in `~/.bnbchaind`
20+
- Client executables stored in `/usr/local/bin` (i.e. `light` or `bnbchaind`)
2121

2222
```shell
2323
# One-line install
@@ -55,24 +55,26 @@ We currently use this repo to store historical versions of the compiled `node-bi
5555

5656
### Running a Full Node
5757

58-
* Step-by-step tutorial at [full node docs](https://docs.binance.org/fullnode.html)
59-
* [Common issues when running a full node](https://docs.binance.org/fullnodeissue.html#common-issues-when-running-a-full-node)
58+
- Step-by-step tutorial at [full node docs](https://docs.binance.org/fullnode.html)
59+
- [Common issues when running a full node](https://docs.binance.org/fullnodeissue.html#common-issues-when-running-a-full-node)
6060

6161
### Running a Light Client
6262

63-
* Step-by-step tutorial at [light client docs](https://docs.binance.org/light-client.html#light-client-versus-full-node)
63+
- Step-by-step tutorial at [light client docs](https://docs.binance.org/light-client.html#light-client-versus-full-node)
6464

6565
## Uninstalling
6666

67-
* Delete the `~/bnbchaind` directory and subdirectories
68-
* Delete the `bnbchaind` or `lightd` executable
67+
- Delete the `~/bnbchaind` directory and subdirectories
68+
- Delete the `bnbchaind` or `lightd` executable
6969

7070
_**Example**: If you installed using installation script_:
71+
7172
```
7273
rm -rf ~/.bnbchaind
7374
rm /usr/local/bin/lightd
7475
rm /usr/local/bin/bnbchaind
7576
```
77+
7678
### Common Issues and Solutions
7779

7880
https://docs.binance.org/fullnodeissue.html
@@ -83,5 +85,6 @@ https://docs.binance.org/fullnodeissue.html
8385
2. [Token Issue&Listing GUI](https://github.com/binance-chain/chain-tooling/tree/airdrop/token-app)
8486

8587
## Resrouces
86-
* [Dos Site](https://docs.binance.org/)
87-
* [Wallet](https://docs.binance.org/wallets.html)
88+
89+
- [Dos Site](https://docs.binance.org/)
90+
- [Wallet](https://docs.binance.org/wallets.html)

install.sh

Lines changed: 108 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/sh
22
# Install script for Binance Chain
3+
# - CLI (bnbcli)
4+
# - Full Node client (bnbchaind)
5+
# - Light Node client (lightd)
6+
# - Installs both testnet and prod
7+
38
# Note: this is based on current structure of `node-binary` repo, which is not optimal
4-
# Future improvement: version binaries using git, instead of folder structure
9+
# - The installer script is a hack to simplify the installation process
10+
# - Our binaries should eventually be refactor into a `apt` or `npm` repo, which features upgradability
11+
# - We should not rely on folders for addressing (instead use git branches for versions)
512

613
# Detect operating system
714
# Future Improvement: Refactor into helper function
@@ -58,121 +65,119 @@ echo "Installer Version: 0.1.beta"
5865
echo "Detected OS: $DETECTED_OS"
5966
echo "====================================================="
6067

61-
# Variables
62-
BNC_HOME_CONFIG_DIR=$BNC_HOME_DIR"/config"
68+
# Links to Documentation
6369
FULLNODE_DOCS_WEB_LINK="https://docs.binance.org/fullnode.html"
6470
LIGHTNODE_DOCS_WEB_LINK="https://docs.binance.org/light-client.html"
65-
GH_REPO_URL="https://github.com/binance-chain/node-binary"
66-
GH_RAW_PREFIX="raw/master"
67-
GH_REPO_DL_URL="$GH_REPO_URL/$GH_RAW_PREFIX"
6871

6972
# Install location
7073
USR_LOCAL_BIN="/usr/local/bin"
7174
# Note: /usr/local/bin choice from https://unix.stackexchange.com/questions/259231/difference-between-usr-bin-and-usr-local-bin
7275
# Future improvement: needs uninstall script (brew uninstall) that removes executable from bin
7376

74-
# Choose Home Directory
75-
BNC_HOME_DIR=${BNC_HOME_DIR:-"$HOME/.bnbchaind"}
76-
read -e -p "Choose home directory [default: ~/.bnbchaind]:" BNC_HOME_DIR
77-
78-
# Choose network option
79-
echo "... Choose Network Version"
80-
OPTION_NETWORK=("Mainnet" "Testnet")
81-
PS3='Choose Network Type: '
82-
select opt in "${OPTION_NETWORK[@]}"; do
83-
case $opt in
84-
"Mainnet")
85-
NETWORK="prod"
86-
break
87-
;;
88-
"Testnet")
89-
NETWORK="testnet"
90-
break
91-
;;
92-
esac
93-
done
77+
# Choose Full Node Directory
78+
read -e -p "Choose home directory for Full Node [default: ~/.bnbchaind]:" BNC_FULLNODE_DIR
79+
BNC_FULLNODE_DIR=${BNC_FULLNODE_DIR:-"$HOME/.bnbchaind"}
80+
81+
# Choose BNBCLI directory
82+
read -e -p "Choose home directory for CLI [default: ~/.bnbcli]:" BNC_CLI_DIR
83+
BNC_CLI_DIR=${BNC_CLI_DIR:-"$HOME/.bnbcli"}
84+
85+
# Choose Light Node directory
86+
read -e -p "Choose home directory for Light Node [default: ~/.binance-lite]:" BNC_LIGHTNODE_DIR
87+
BNC_LIGHTNODE_DIR=${BNC_LIGHTNODE_DIR:-"$HOME/.binance-lite"}
88+
89+
# Detect previous installation and create .bnbchaind folder,
90+
BNC_FULLNODE_CONFIG_DIR="$BNC_FULLNODE_DIR/config"
91+
echo "... creating $BNC_FULLNODE_DIR"
92+
if [ -d "$BNC_FULLNODE_DIR" ]; then
93+
echo "... Error: Binance Chain Fullnode has already been installed"
94+
echo "... Error: Please remove contents of ${BNC_FULLNODE_DIR} before reinstalling."
95+
exit 1
96+
else
97+
mkdir -p $BNC_FULLNODE_CONFIG_DIR
98+
cd $BNC_FULLNODE_DIR
99+
fi
100+
if [ -f "$USR_LOCAL_BIN/bnbchaind" ]; then
101+
echo "... Error: Binance Chain Fullnode has already been installed"
102+
echo "... Error: Please remove bnbchaind from /usr/local/bin before reinstalling."
103+
exit 1
104+
fi
105+
if [ -f "$USR_LOCAL_BIN/lightd" ]; then
106+
echo "... Error: Binance Chain Light Node has already been installed"
107+
echo "... Error: Please remove lightd from /usr/local/bin before reinstalling."
108+
exit 1
109+
fi
110+
if [ -f "$USR_LOCAL_BIN/bnbcli" ]; then
111+
echo "... Error: Binance Chain CLI Mainnet has already been installed"
112+
echo "... Error: Please remove bnbcli from /usr/local/bin before reinstalling."
113+
exit 1
114+
fi
115+
if [ -f "$USR_LOCAL_BIN/tbnbcli" ]; then
116+
echo "... Error: Binance Chain CLI Testnet has already been installed"
117+
echo "... Error: Please remove tbnbcli from /usr/local/bin before reinstalling."
118+
exit 1
119+
fi
94120

95121
# Version selection options
96122
# Future improvement: pull dynamically from version list
97-
OPTION_VERSION_NUMBER=("0.5.8" "0.5.9" "0.5.10" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
98-
OPTION_NODE_TYPE=("Full Node" "Light Node")
99-
100-
echo "... Choose version of Binance Chain node to install"
101-
PS3='Choose Version Number: '
102-
select opt in "${OPTION_VERSION_NUMBER[@]}"; do
103-
VERSION_NUMBER="$opt"
104-
break
105-
done
106123

107-
echo "... Choose node type to install"
108-
PS3='Choose Node Type: '
109-
select opt in "${OPTION_NODE_TYPE[@]}"; do
110-
case $opt in
111-
"Full Node")
112-
NODE_TYPE="fullnode"
113-
break
114-
;;
115-
"Light Node")
116-
NODE_TYPE="lightnode"
117-
break
118-
;;
119-
esac
120-
done
124+
CLI_LATEST_VERSION="0.6.3"
125+
# 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")
126+
# 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")
121127

122-
# Download the selected binary
123-
# Future improvement: versions should just be a single .zip payload (e.g. 0.6.2)
124-
# Future improvement: should not use folder structure as addressing method
125-
VERSION_PATH="$NODE_TYPE/$NETWORK/$VERSION_NUMBER"
126-
GH_BASE_URL="$GH_REPO_URL/$GH_RAW_PREFIX/$VERSION_PATH"
127-
CONFIG_DOWNLOAD_URL="$GH_BASE_URL/config"
128-
NODE_BINARY_DOWNLOAD_URL="$GH_BASE_URL/$DETECTED_OS"
129-
130-
# wget the binary, config files
131-
# Future improvement: should refactor in the future with releases in a single .zip or .tar.gz file
132-
if [ $NODE_TYPE == "fullnode" ]; then
133-
134-
# Detect previous installation and create .bnbchaind
135-
echo "... creating $BNC_HOME_DIR"
136-
if [ -d "$BNC_HOME_DIR" ]; then
137-
echo "... Error: Binance Chain Fullnode has already been installed"
138-
echo "... Error: Please remove contents of ${BNC_HOME_DIR} before reinstalling."
139-
exit 1
128+
FULLNODE_LATEST_VERSION="0.6.3-hotfix"
129+
# 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")
130+
# 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")
131+
132+
LIGHTNODE_LATEST_VERSION="0.6.3"
133+
# LIGHTNODE_PROD_VERSION_NUMBERS=("0.5.8" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
134+
# LIGHTNODE_TESTNET_VERSION_NUMBERS=("0.5.8" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
135+
136+
# File Download URLs
137+
GH_REPO_URL="https://github.com/binance-chain/node-binary/raw/master"
138+
139+
# Download both Testnet and Mainnet CLI
140+
for NETWORK in "prod" "testnet"; do
141+
if [ "$NETWORK" = "prod" ]; then
142+
FILENAME="bnbcli"
140143
else
141-
mkdir -p $BNC_HOME_CONFIG_DIR
142-
cd $BNC_HOME_DIR
144+
FILENAME="tbnbcli"
143145
fi
144-
if [ -f "$USR_LOCAL_BIN/bnbchaind" ]; then
145-
echo "... Error: Binance Chain Fullnode has already been installed"
146-
echo "... Error: Please remove bnbchaind from /usr/local/bin before reinstalling."
147-
exit 1
148-
fi
149-
150-
# Future improvement: should be refactored into helper function
146+
CLI_VERSION_PATH="cli/$NETWORK/$CLI_LATEST_VERSION/$DETECTED_OS/$FILENAME"
147+
CLI_BINARY_URL="$GH_REPO_URL/$CLI_VERSION_PATH"
151148
cd $USR_LOCAL_BIN
152-
echo "... Downloading bnbchaind executable"
153-
wget -q --show-progress "$NODE_BINARY_DOWNLOAD_URL/bnbchaind"
154-
chmod 755 "./bnbchaind"
155-
156-
cd $BNC_HOME_CONFIG_DIR
157-
echo "... Downloading config files for version"
158-
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/app.toml"
159-
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/config.toml"
160-
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/genesis.json"
161-
162-
# Add installed version of Binance Chain to path
163-
echo "... Installation successful!"
164-
echo "... \`bnbchaind\` added to $USR_LOCAL_BIN"
165-
echo "... Visit full node documentation at $DOCS_WEB_LINK"
166-
echo "... Run \`bnbchaind\` to see list of available commands"
167-
168-
elif [ $NODE_TYPE == "lightnode" ]; then
169-
cd $USR_LOCAL_BIN
170-
echo "... Downloading lightd executable"
171-
wget -q --show-progress "$NODE_BINARY_DOWNLOAD_URL/lightd"
172-
chmod 755 "./lightd"
173-
174-
echo "... Installation successful!"
175-
echo "... \`lightd\` added to $USR_LOCAL_BIN"
176-
echo "... Visit full node documentation at $DOCS_WEB_LINK"
177-
echo "... Run \`lightd\` to see list of available commands"
178-
fi
149+
echo "... Downloading $FILENAME executable version:" $CLI_LATEST_VERSION
150+
wget -q --show-progress "$CLI_BINARY_URL"
151+
chmod 755 "./$FILENAME"
152+
done
153+
154+
# Download Light Node
155+
LIGHTNODE_VERSION_PATH="lightnode/prod/$LIGHTNODE_LATEST_VERSION/$DETECTED_OS"
156+
LIGHTNODE_BINARY_URL="$GH_REPO_URL/$LIGHTNODE_VERSION_PATH/lightd"
157+
158+
cd $USR_LOCAL_BIN
159+
echo "... Downloading lightd executable version:" $LIGHTNODE_LATEST_VERSION
160+
wget -q --show-progress "$LIGHTNODE_BINARY_URL"
161+
chmod 755 "./lightd"
162+
163+
# Download Full Node
164+
FULLNODE_VERSION_PATH="fullnode/prod/$FULLNODE_LATEST_VERSION"
165+
FULLNODE_CONFIG_URL="$GH_REPO_URL/$FULLNODE_VERSION_PATH/config"
166+
FULLNODE_BINARY_URL="$GH_REPO_URL/$FULLNODE_VERSION_PATH/$DETECTED_OS/bnbchaind"
167+
168+
cd $BNC_FULLNODE_CONFIG_DIR
169+
echo "... Downloading config files for full node"
170+
wget -q --show-progress "$FULLNODE_CONFIG_URL/app.toml"
171+
wget -q --show-progress "$FULLNODE_CONFIG_URL/config.toml"
172+
wget -q --show-progress "$FULLNODE_CONFIG_URL/genesis.json"
173+
174+
cd $USR_LOCAL_BIN
175+
echo "... Downloading bnbchaind executable version:" $FULLNODE_LATEST_VERSION
176+
wget -q --show-progress "$FULLNODE_BINARY_URL"
177+
chmod 755 "./bnbchaind"
178+
179+
# exit 1
180+
181+
# Add installed version of Binance Chain to path
182+
echo "... Installation successful!"
183+
echo "... \`bnbcli\`, \`tbnbcli\`, \`bnbchaind\`, \`lightd\` added to $USR_LOCAL_BIN"

0 commit comments

Comments
 (0)