|
1 | 1 | #!/bin/sh |
2 | 2 | # 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 | + |
3 | 8 | # 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) |
5 | 12 |
|
6 | 13 | # Detect operating system |
7 | 14 | # Future Improvement: Refactor into helper function |
@@ -58,121 +65,119 @@ echo "Installer Version: 0.1.beta" |
58 | 65 | echo "Detected OS: $DETECTED_OS" |
59 | 66 | echo "=====================================================" |
60 | 67 |
|
61 | | -# Variables |
62 | | -BNC_HOME_CONFIG_DIR=$BNC_HOME_DIR"/config" |
| 68 | +# Links to Documentation |
63 | 69 | FULLNODE_DOCS_WEB_LINK="https://docs.binance.org/fullnode.html" |
64 | 70 | 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 | 71 |
|
69 | 72 | # Install location |
70 | 73 | USR_LOCAL_BIN="/usr/local/bin" |
71 | 74 | # Note: /usr/local/bin choice from https://unix.stackexchange.com/questions/259231/difference-between-usr-bin-and-usr-local-bin |
72 | 75 | # Future improvement: needs uninstall script (brew uninstall) that removes executable from bin |
73 | 76 |
|
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 |
94 | 120 |
|
95 | 121 | # Version selection options |
96 | 122 | # 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 | 123 |
|
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") |
121 | 127 |
|
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" |
140 | 143 | else |
141 | | - mkdir -p $BNC_HOME_CONFIG_DIR |
142 | | - cd $BNC_HOME_DIR |
| 144 | + FILENAME="tbnbcli" |
143 | 145 | 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" |
151 | 148 | 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