Skip to content

Commit 651930d

Browse files
dan-menlochainwhisper
authored andcommitted
Installation script (bnb-chain#173)
* 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
1 parent 661c459 commit 651930d

File tree

2 files changed

+242
-2
lines changed

2 files changed

+242
-2
lines changed

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
1-
# node-binary
2-
Binaries for full nodes, light-weighted clients and user clients.
1+
# Binance Chain Client
32

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.
4+
5+
* [Match logic](https://docs.binance.org/match.html)
6+
* [Anti-front running](https://docs.binance.org/anti-frontrun.html)
7+
8+
Binance Chain clients are released as compiled executables in this repo, with a few variants:
9+
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
12+
13+
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).
14+
15+
## Installation Script
16+
17+
We have a community-maintained installer script (`install.sh`) that takes care of chain directory setup. This uses the following defaults:
18+
19+
* Home folder in `~/.bnbchaind`
20+
* Client executables stored in `/usr/local/bin` (i.e. `light` or `bnbchaind`)
21+
22+
```shell
23+
# One-line install
24+
sh <(wget -qO- https://raw.githubusercontent.com/onggunhao/node-binary/master/install.sh)
25+
```
26+
27+
> In the future, we may release an official installer script
28+
> e.g. `sh <(wget -qO- https://get.binance.org)`
29+
30+
## Manual Installation
31+
32+
We currently use this repo to store historical versions of the compiled `node-binaries`.
33+
34+
### Running a Full Node
35+
36+
* Step-by-step tutorial at [full node docs](https://docs.binance.org/fullnode.html)
37+
* [Common issues when running a full node](https://docs.binance.org/fullnodeissue.html#common-issues-when-running-a-full-node)
38+
39+
### Running a Light Client
40+
41+
* Step-by-step tutorial at [light client docs](https://docs.binance.org/light-client.html#light-client-versus-full-node)
42+
43+
## Uninstalling
44+
45+
* Delete the `~/bnbchaind` directory and subdirectories
46+
* Delete the `bnbchaind` or `lightd` executable
47+
48+
_**Example**: If you installed using installation script_:
49+
```
50+
rm -rf ~/.bnbchaind
51+
rm /usr/local/bin/lightd
52+
rm /usr/local/bin/bnbchaind
53+
```
54+
### Common Issues and Solutions
55+
56+
https://docs.binance.org/fullnodeissue.html
57+
58+
# Tools
59+
60+
1. [Airdrop Tool](https://github.com/binance-chain/chain-tooling#airdrop)
61+
2. [Token Issue&Listing GUI](https://github.com/binance-chain/chain-tooling/tree/airdrop/token-app)
62+
63+
## Resrouces
64+
* [Dos Site](https://docs.binance.org/)
65+
* [Wallet](https://docs.binance.org/wallets.html)

install.sh

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#!/bin/sh
2+
# Install script for Binance Chain
3+
# 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
5+
6+
# Detect operating system
7+
# Future Improvement: Refactor into helper function
8+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
9+
DETECTED_OS="linux"
10+
elif [[ "$OSTYPE" == "darwin"* ]]; then
11+
DETECTED_OS="mac"
12+
elif [[ "$OSTYPE" == "cygwin" ]]; then
13+
DETECTED_OS="linux"
14+
elif [[ "$OSTYPE" == "msys" ]]; then
15+
DETECTED_OS="windows"
16+
elif [[ "$OSTYPE" == "win32" ]]; then
17+
DETECTED_OS="windows" # TODO(Dan): can you run shell on windows?
18+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
19+
DETECTED_OS="linux"
20+
else
21+
FULLNODE_echo "Error: unable to detect operating system. Please install manually by referring to $DOCS_WEB_LINK"
22+
LIGHTNODE_DOCS_WEB_LINK=""
23+
exit 1
24+
fi
25+
26+
# Check for existence of wget
27+
if [ ! -x /usr/bin/wget ]; then
28+
# some extra check if wget is not installed at the usual place
29+
command -v wget >/dev/null 2>&1 || {
30+
echo >&2 "Error: you need to have wget installed and in your path. Use brew (mac) or apt (unix) to install wget"
31+
exit 1
32+
}
33+
fi
34+
35+
echo "@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@"
36+
echo "@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@"
37+
echo "@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@"
38+
echo "@@@@@@@@@@@@@ @@@@@@@@@@@@@"
39+
echo "@@@@@@@@@@@ @@@@@@@@@@@"
40+
echo "@@@@@@@@@ @@@ @@@@@@@@@"
41+
echo "@@@@@@@@ @@@@@@@ @@@@@@@@"
42+
echo "@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@"
43+
echo "@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@"
44+
echo "@ @@@@@@@@ @@@@@@@@ @"
45+
echo "@ @@@@@@@@ @@@@@@@@ @"
46+
echo "@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@"
47+
echo "@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@"
48+
echo "@@@@@@@@ @@@@@@@ @@@@@@@@"
49+
echo "@@@@@@@@@ @@@ @@@@@@@@@"
50+
echo "@@@@@@@@@@@ @@@@@@@@@@@"
51+
echo "@@@@@@@@@@@@@ @@@@@@@@@@@@@"
52+
echo "@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@"
53+
echo "@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@"
54+
echo ""
55+
56+
echo "========== Binance Chain Node Installation =========="
57+
echo "Installer Version: 0.1.beta"
58+
echo "Detected OS: $DETECTED_OS"
59+
echo "====================================================="
60+
61+
# Variables
62+
BNC_HOME_CONFIG_DIR=$BNC_HOME_DIR"/config"
63+
FULLNODE_DOCS_WEB_LINK="https://docs.binance.org/fullnode.html"
64+
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"
68+
69+
# Install location
70+
USR_LOCAL_BIN="/usr/local/bin"
71+
# Note: /usr/local/bin choice from https://unix.stackexchange.com/questions/259231/difference-between-usr-bin-and-usr-local-bin
72+
# Future improvement: needs uninstall script (brew uninstall) that removes executable from bin
73+
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
94+
95+
# Version selection options
96+
# 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
106+
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
121+
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
140+
else
141+
mkdir -p $BNC_HOME_CONFIG_DIR
142+
cd $BNC_HOME_DIR
143+
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
151+
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

0 commit comments

Comments
 (0)