From d1884ad8eb85b1128bb878b97018d532e6f4b890 Mon Sep 17 00:00:00 2001 From: Jon Layton Date: Wed, 11 Apr 2018 11:25:08 -0500 Subject: [PATCH] Renamed and cleaned up setup scripts --- btcp_old_node_setup.sh => btcp_basic_node.sh | 15 -- build_btcp.sh => btcp_daemon_only.sh | 0 ..._node_setup.sh => btcp_explorer_upgrade.sh | 46 +----- btcp_v5_node_setup.sh => btcp_node_v5.sh | 0 btcp_store_demo.sh | 139 +++++++++++------- start.sh => start_v5.sh | 3 +- 6 files changed, 94 insertions(+), 109 deletions(-) rename btcp_old_node_setup.sh => btcp_basic_node.sh (84%) rename build_btcp.sh => btcp_daemon_only.sh (100%) rename btcp_node_setup.sh => btcp_explorer_upgrade.sh (78%) rename btcp_v5_node_setup.sh => btcp_node_v5.sh (100%) rename start.sh => start_v5.sh (75%) diff --git a/btcp_old_node_setup.sh b/btcp_basic_node.sh similarity index 84% rename from btcp_old_node_setup.sh rename to btcp_basic_node.sh index ce8031e..812d878 100755 --- a/btcp_old_node_setup.sh +++ b/btcp_basic_node.sh @@ -60,21 +60,6 @@ cd btcp-explorer # Install Insight API / UI (Explorer) (Headless) ../node_modules/bitcore-node-btcp/bin/bitcore-node install BTCPrivate/insight-api-btcp BTCPrivate/insight-ui-btcp -# !!! OPTIONAL [TODO present cli options] Install store-demo -cd ~ -git clone https://github.com/BTCPrivate/store-demo -cd btcp-explorer/node_modules -ln -s ~/store-demo - -# !!! OPTIONAL [TODO present cli options] Install address-watch -cd ~ -git clone https://github.com/BTCPrivate/address-watch -cd btcp-explorer/node_modules -ln -s ~/address-watch - -# Create config file for Bitcore -# !!! OPTIONAL TODO add store-demo and address-watch to services as specified - # Create config file for Bitcore cat << EOF > bitcore-node.json { diff --git a/build_btcp.sh b/btcp_daemon_only.sh similarity index 100% rename from build_btcp.sh rename to btcp_daemon_only.sh diff --git a/btcp_node_setup.sh b/btcp_explorer_upgrade.sh similarity index 78% rename from btcp_node_setup.sh rename to btcp_explorer_upgrade.sh index e30b897..fce207b 100755 --- a/btcp_node_setup.sh +++ b/btcp_explorer_upgrade.sh @@ -24,8 +24,8 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -# Install node v9, or v4 for <=4.0 -nvm install v9 #v4 +# Install node v9 +nvm install v9 # Fetch BTCP + Build from source ./build_btcp.sh @@ -39,12 +39,13 @@ npm install npm-run-all -g cd ~ + mkdir btcp-bitcore-node cd btcp-bitcore-node # Install Bitcore (Headless) -nvm use v9 #v4 -npm install ch4ot1c/bitcore-node # or #4.0-btcp for daemon-compatible(?) +nvm use v9 +npm install ch4ot1c/bitcore-node # or branch 4.0-btcp (?) # Create Bitcore Node ./node_modules/bitcore-node/bin/bitcore-node create btcp-node @@ -57,6 +58,7 @@ cd btcp-node cd node_modules npm install ch4ot1c/insight-api ch4ot1c/insight --save +# Service Installation Instructions from BitPay site (for newer versions of bitcore/bitcore-node, wip): # !!! OPTIONAL [TODO present cli options] Install store-demo #cd ~ #git clone https://github.com/BTCPrivate/store-demo @@ -72,39 +74,7 @@ npm install ch4ot1c/insight-api ch4ot1c/insight --save # Create config file for Bitcore # !!! OPTIONAL TODO add store-demo and address-watch to services as specified -# Create config file for Bitcore -: ' -# daemon (4.0) (bitcoind, as opposed to bcoin) -cat << EOF > bitcore-node.json -{ - "network": "livenet", - "port": 8001, - "services": [ - "bitcoind", - "insight-api", - "insight-ui", - "web" - ], - "servicesConfig": { - "bitcoind": { - "spawn": { - "datadir": "$HOME/.btcprivate", - "exec": "$HOME/BitcoinPrivate/src/btcpd" - } - }, - "insight-ui": { - "apiPrefix": "api", - "routePrefix": "" - }, - "insight-api": { - "routePrefix": "api" - } - } -} -EOF -' - -# daemon (5.0) (bcoin) +# daemon (5.0) (uses bcoin) # optional - add bitcore-wallet-service cat << EOF > bitcore-node.json { @@ -150,7 +120,7 @@ EOF echo "To start the daemon and all services, run:" -echo "./start.sh" +echo "bitcore start" echo "\n" echo "To view the explorer in your browser - http://server_ip:8001" echo "For https, we recommend you route through Cloudflare." diff --git a/btcp_v5_node_setup.sh b/btcp_node_v5.sh similarity index 100% rename from btcp_v5_node_setup.sh rename to btcp_node_v5.sh diff --git a/btcp_store_demo.sh b/btcp_store_demo.sh index 4100741..8e40a99 100755 --- a/btcp_store_demo.sh +++ b/btcp_store_demo.sh @@ -1,8 +1,9 @@ #!/bin/bash -# Bitcore v3.1 - BTCP Explorer + Store / AddressWatch Demo +# BTCP Bitcore API + Explorer + Store / AddressWatch Demo install_ubuntu() { + # Get Ubuntu Dependencies sudo apt-get update @@ -11,59 +12,68 @@ sudo apt-get -y install \ autoconf libtool ncurses-dev unzip git python \ zlib1g-dev wget bsdmainutils automake - # Install ZeroMQ libraries (Bitcore) - sudo apt-get -y install libzmq3-dev +# Install ZeroMQ libraries (Bitcore) +sudo apt-get -y install libzmq3-dev } +make_swapfile() { + +# WARNING: You must have a big Swapfile for the installation to succeed +# !!! EC2 Micro - Make sure you have a big enough Swapfile +# +#prev=$PWD +#cd / +#sudo dd if=/dev/zero of=swapfile bs=1M count=3000 +#sudo mkswap swapfile +#sudo chmod 0600 /swapfile +#sudo swapon swapfile +#echo "/swapfile none swap sw 0 0" | sudo tee -a etc/fstab > /dev/null +#cd prev + +} + clone_and_build_btcp() { - # Clone latest Bitcoin Private source, and checkout explorer-btcp - git clone -b explorer-btcp https://github.com/BTCPrivate/BitcoinPrivate - cd BitcoinPrivate - # Fetch Zcash ceremony params - ./btcputil/fetch-params.sh +# Clone latest Bitcoin Private source, and checkout explorer-btcp +git clone -b explorer-btcp https://github.com/BTCPrivate/BitcoinPrivate +cd BitcoinPrivate - # !!! OPTIONAL: EC2 - Make sure port 8001 is in your security group - # !!! OPTIONAL: EC2 Micro - Make sure you have a big enough Swapfile - #prev=$PWD - #cd / - #sudo dd if=/dev/zero of=swapfile bs=1M count=3000 - #sudo mkswap swapfile - #sudo chmod 0600 /swapfile - #sudo swapon swapfile - #echo "/swapfile none swap sw 0 0" | sudo tee -a etc/fstab > /dev/null - #cd prev +# Fetch BTCP/Zcash ceremony params +./btcputil/fetch-params.sh - # Build Bitcoin Private - ./btcputil/build.sh -j$(nproc) +# Build Bitcoin Private +./btcputil/build.sh -j$(nproc) + +# Make initial, empty btcprivate.conf if needed +if [ ! -e ~/.btcprivate/btcprivate.conf ] +then + touch ~/.btcprivate/btcprivate.conf +fi - # Make initial, empty btcprivate.conf if needed - if [ ! -e ~/.btcprivate/btcprivate.conf ] - then - touch ~/.btcprivate/btcprivate.conf - fi } install_nvm_npm() { - # Install npm - sudo apt-get -y install npm - # Install nvm (npm version manager) - wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash +# Install npm +sudo apt-get -y install npm - # Set up nvm - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +# Install nvm (npm version manager) +wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash + +# Set up nvm +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Install node v4 +nvm install v4 +nvm use v4 +nvm alias default v4 - # Install node v4 - nvm install v4 - nvm use v4 - nvm alias default v4 } -# For bitcore-wallet-service: +# MongoDB dependency for bitcore-wallet-service: install_mongodb() { @@ -93,22 +103,12 @@ cd btcp-explorer # (BTCPrivate/address-watch) # (mv store-demo lemonade-stand) -# !!! OPTIONAL [TODO present cli options] Install store-demo -#cd ~ -#git clone https://github.com/BTCPrivate/store-demo -#cd btcp-explorer/node_modules -#ln -s ~/store-demo - - -# !!! OPTIONAL [TODO present cli options] Install address-watch -#cd ~ -#git clone https://github.com/BTCPrivate/address-watch -#cd btcp-explorer/node_modules -#ln -s ~/address-watch # Create config file for Bitcore # !!! OPTIONAL TODO add store-demo and address-watch to services as specified +# !!! EC2 - Make sure port 8001 is in your security group + cat << EOF > bitcore-node.json { "network": "livenet", @@ -141,14 +141,24 @@ EOF } # Begin -echo "Begin Setup." -echo \n - cd ~ -#clone_and_build_btcp +echo "Begin Setup." +echo \n +echo "Can we make you a 3gb swapfile? It takes a lot of memory to build BTCP." +read -r -p "[y/N] " response +case "$response" in + [yY][eE][sS]|[yY]) + make_swapfile + clone_and_build_btcp + ;; + *) + clone_and_build_btcp + ;; +esac -#install_nvm_npm + +install_nvm_npm #install_mongodb @@ -162,3 +172,22 @@ echo "nvm use v4; ./node_modules/bitcore-node/bin/bitcore-node start" echo \n echo "To view the explorer in your browser - http://server_ip:8001" echo "For https, we recommend you route through Cloudflare. bitcore-node also supports it via the config; provide certs." + + + +# Service Installation Instructions from BitPay site (for newer versions of bitcore/bitcore-node, wip): + +# !!! OPTIONAL [TODO present cli options] Install store-demo +#cd ~ +#git clone https://github.com/BTCPrivate/store-demo +#cd btcp-explorer/node_modules +#ln -s ~/store-demo + + +# !!! OPTIONAL [TODO present cli options] Install address-watch +#cd ~ +#git clone https://github.com/BTCPrivate/address-watch +#cd btcp-explorer/node_modules +#ln -s ~/address-watch + + diff --git a/start.sh b/start_v5.sh similarity index 75% rename from start.sh rename to start_v5.sh index dae8289..cf1af9c 100755 --- a/start.sh +++ b/start_v5.sh @@ -9,5 +9,6 @@ export NVM_DIR="$HOME/.nvm" # For >= 5.0 (bitpay website instructions) nvm use v9; bitcored -# For v3.1: cd btcp-explorer; nvm use v4; ./node_modules/bitcore-node/bin/bitcore-node start +# For earlier versions: +# cd btcp-explorer; nvm use v4; ./node_modules/bitcore-node/bin/bitcore-node start