Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Installation script (#173)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dan-menlo authored and chainwhisper committed Dec 18, 2019
1 parent 661c459 commit 651930d
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 2 deletions.
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
# node-binary
Binaries for full nodes, light-weighted clients and user clients.
# Binance Chain Client

[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.

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

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

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

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).

## Installation Script

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

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

```shell
# One-line install
sh <(wget -qO- https://raw.githubusercontent.com/onggunhao/node-binary/master/install.sh)
```

> In the future, we may release an official installer script
> e.g. `sh <(wget -qO- https://get.binance.org)`
## Manual Installation

We currently use this repo to store historical versions of the compiled `node-binaries`.

### Running a Full Node

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

### Running a Light Client

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

## Uninstalling

* Delete the `~/bnbchaind` directory and subdirectories
* Delete the `bnbchaind` or `lightd` executable

_**Example**: If you installed using installation script_:
```
rm -rf ~/.bnbchaind
rm /usr/local/bin/lightd
rm /usr/local/bin/bnbchaind
```
### Common Issues and Solutions

https://docs.binance.org/fullnodeissue.html

# Tools

1. [Airdrop Tool](https://github.com/binance-chain/chain-tooling#airdrop)
2. [Token Issue&Listing GUI](https://github.com/binance-chain/chain-tooling/tree/airdrop/token-app)

## Resrouces
* [Dos Site](https://docs.binance.org/)
* [Wallet](https://docs.binance.org/wallets.html)
178 changes: 178 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/sh
# Install script for Binance Chain
# Note: this is based on current structure of `node-binary` repo, which is not optimal
# Future improvement: version binaries using git, instead of folder structure

# 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 "====================================================="

# Variables
BNC_HOME_CONFIG_DIR=$BNC_HOME_DIR"/config"
FULLNODE_DOCS_WEB_LINK="https://docs.binance.org/fullnode.html"
LIGHTNODE_DOCS_WEB_LINK="https://docs.binance.org/light-client.html"
GH_REPO_URL="https://github.com/binance-chain/node-binary"
GH_RAW_PREFIX="raw/master"
GH_REPO_DL_URL="$GH_REPO_URL/$GH_RAW_PREFIX"

# 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 Home Directory
BNC_HOME_DIR=${BNC_HOME_DIR:-"$HOME/.bnbchaind"}
read -e -p "Choose home directory [default: ~/.bnbchaind]:" BNC_HOME_DIR

# Choose network option
echo "... Choose Network Version"
OPTION_NETWORK=("Mainnet" "Testnet")
PS3='Choose Network Type: '
select opt in "${OPTION_NETWORK[@]}"; do
case $opt in
"Mainnet")
NETWORK="prod"
break
;;
"Testnet")
NETWORK="testnet"
break
;;
esac
done

# Version selection options
# Future improvement: pull dynamically from version list
OPTION_VERSION_NUMBER=("0.5.8" "0.5.9" "0.5.10" "0.6.0" "0.6.1" "0.6.2" "0.6.3")
OPTION_NODE_TYPE=("Full Node" "Light Node")

echo "... Choose version of Binance Chain node to install"
PS3='Choose Version Number: '
select opt in "${OPTION_VERSION_NUMBER[@]}"; do
VERSION_NUMBER="$opt"
break
done

echo "... Choose node type to install"
PS3='Choose Node Type: '
select opt in "${OPTION_NODE_TYPE[@]}"; do
case $opt in
"Full Node")
NODE_TYPE="fullnode"
break
;;
"Light Node")
NODE_TYPE="lightnode"
break
;;
esac
done

# Download the selected binary
# Future improvement: versions should just be a single .zip payload (e.g. 0.6.2)
# Future improvement: should not use folder structure as addressing method
VERSION_PATH="$NODE_TYPE/$NETWORK/$VERSION_NUMBER"
GH_BASE_URL="$GH_REPO_URL/$GH_RAW_PREFIX/$VERSION_PATH"
CONFIG_DOWNLOAD_URL="$GH_BASE_URL/config"
NODE_BINARY_DOWNLOAD_URL="$GH_BASE_URL/$DETECTED_OS"

# wget the binary, config files
# Future improvement: should refactor in the future with releases in a single .zip or .tar.gz file
if [ $NODE_TYPE == "fullnode" ]; then

# Detect previous installation and create .bnbchaind
echo "... creating $BNC_HOME_DIR"
if [ -d "$BNC_HOME_DIR" ]; then
echo "... Error: Binance Chain Fullnode has already been installed"
echo "... Error: Please remove contents of ${BNC_HOME_DIR} before reinstalling."
exit 1
else
mkdir -p $BNC_HOME_CONFIG_DIR
cd $BNC_HOME_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

# Future improvement: should be refactored into helper function
cd $USR_LOCAL_BIN
echo "... Downloading bnbchaind executable"
wget -q --show-progress "$NODE_BINARY_DOWNLOAD_URL/bnbchaind"
chmod 755 "./bnbchaind"

cd $BNC_HOME_CONFIG_DIR
echo "... Downloading config files for version"
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/app.toml"
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/config.toml"
wget -q --show-progress "$CONFIG_DOWNLOAD_URL/genesis.json"

# Add installed version of Binance Chain to path
echo "... Installation successful!"
echo "... \`bnbchaind\` added to $USR_LOCAL_BIN"
echo "... Visit full node documentation at $DOCS_WEB_LINK"
echo "... Run \`bnbchaind\` to see list of available commands"

elif [ $NODE_TYPE == "lightnode" ]; then
cd $USR_LOCAL_BIN
echo "... Downloading lightd executable"
wget -q --show-progress "$NODE_BINARY_DOWNLOAD_URL/lightd"
chmod 755 "./lightd"

echo "... Installation successful!"
echo "... \`lightd\` added to $USR_LOCAL_BIN"
echo "... Visit full node documentation at $DOCS_WEB_LINK"
echo "... Run \`lightd\` to see list of available commands"
fi

0 comments on commit 651930d

Please sign in to comment.