diff --git a/README.md b/README.md index e496ef9..0d4e4a3 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,7 @@ ### Netstats server [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Fdeployment-azure%2Fdev-mainnet%2Fnodes%2Fnetstats-server%2Ftemplate.json) + +### Chain explorer + +[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Fdeployment-azure%2Fdev-mainnet%2Fnodes%2Fexplorer%2Ftemplate.json) diff --git a/nodes/explorer/install.sh b/nodes/explorer/install.sh new file mode 100644 index 0000000..e7d6975 --- /dev/null +++ b/nodes/explorer/install.sh @@ -0,0 +1,172 @@ +#!/bin/bash +set -e +set -u +set -x + +# this should be provided through env by azure template +TEMPLATES_BRANCH="${TEMPLATES_BRANCH}" +MAIN_REPO_FETCH="${MAIN_REPO_FETCH}" + +echo "========== ${TEMPLATES_BRANCH}/explorer/install.sh starting ==========" +echo "===== current time: $(date)" +echo "===== username: $(whoami)" +echo "===== working directory: $(pwd)" +echo "===== operating system info:" +lsb_release -a +echo "===== memory usage info:" +free -m + +EXT_IP="$(curl ifconfig.co)" +echo "===== external ip: ${EXT_IP}" + +echo "===== downloading common.vars" +curl -sLO "https://raw.githubusercontent.com/${MAIN_REPO_FETCH}/deployment-azure/${TEMPLATES_BRANCH}/nodes/common.vars" +source common.vars + +INSTALL_CONFIG_REPO="${REPO_BASE_PATH}/explorer" +echo "===== INSTALL_CONFIG_REPO: ${INSTALL_CONFIG_REPO}" + +# this should be provided through env by azure template +NODE_FULLNAME="${NODE_FULLNAME:-Explorer}" +NODE_ADMIN_EMAIL="${NODE_ADMIN_EMAIL:-somebody@somehere}" +ADMIN_USERNAME="${ADMIN_USERNAME}" + +export HOME="${HOME:-/home/${ADMIN_USERNAME}}" + +echo "===== environmental variables:" +printenv + +echo "===== downloading common.funcs" +curl -sLO "https://raw.githubusercontent.com/${MAIN_REPO_FETCH}/deployment-azure/${TEMPLATES_BRANCH}/nodes/common.funcs" +source common.funcs + +setup_ufw() { + echo "=====> setup_ufw" + sudo sudo ufw enable + sudo ufw default deny incoming + sudo ufw allow 3000 + sudo ufw allow 4000 + sudo ufw allow 443 + sudo ufw allow 8545 + sudo ufw allow 22/tcp + sudo ufw allow 30303/tcp + sudo ufw allow 30303/udp + echo "<===== setup_ufw" +} + +pull_image_and_configs() { + echo "=====> pull_image_and_configs" + # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" + curl -s -o "${GENESIS_JSON}" "${GENESIS_REPO_LOC}" + curl -s -O "${INSTALL_CONFIG_REPO}/node.toml" + curl -s -o "bootnodes.txt" "${BOOTNODES_TXT}" + sed -i "/\[network\]/a nat=\"extip:${EXT_IP}\"" ${NODE_TOML} + #sed -i "/\[network\]/a bootnodes=\[$(cat bootnodes.txt | sed 's/\r$//' | awk -F'#' '{ print $1 }' | awk '/enode/{ print "\""$1"\"" }' | paste -sd "," -)\]" ${NODE_TOML} + sed -i "/\[network\]/a reserved_peers=\"/home/${ADMIN_USERNAME}/bootnodes.txt\"" ${NODE_TOML} + cat >> ${NODE_TOML} < install_chain_explorer_via_systemd" + git clone https://github.com/oraclesorg/chain-explorer + git clone https://github.com/ethereum/solc-bin chain-explorer/utils/solc-bin + cd chain-explorer + npm install + sudo npm install pm2 -g + cat > config.js < app.json << EOF +[ + { + "name" : "explorer", + "script" : "./bin/www", + "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", + "error_file" : "/home/${ADMIN_USERNAME}/logs/explorer.err", + "out_file" : "/home/${ADMIN_USERNAME}/logs/explorer.out", + "merge_logs" : false, + "watch" : false, + "max_restarts" : 100, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "PORT" : 4000, + } + } +] +EOF + cd .. + sudo bash -c "cat > /etc/systemd/system/oracles-chain-explorer.service <