#!/bin/bash set -e set -u set -x TEMPLATES_BRANCH="dev-mainnet" echo "========== ${TEMPLATES_BRANCH}/netstats-server/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 echo "===== downloading common.vars" curl -sLO "https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/TestTestNet/common.vars" source common.vars EXT_IP="$(curl ifconfig.co)" echo "===== external ip: ${EXT_IP}" NETSTATS_SERVER="localhost" INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/TestTestNet/netstats-server" echo "===== repo base path: ${INSTALL_CONFIG_REPO}" # this should be provided through env by azure template NETSTATS_SECRET="${NETSTATS_SECRET}" NODE_FULLNAME="${NODE_FULLNAME:-NetStat}" 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/oraclesorg/test-templates/${TEMPLATES_BRANCH}/TestTestNet/common.funcs" source common.funcs setup_ufw() { echo "=====> setup_ufw" sudo sudo ufw enable sudo ufw default deny incoming 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_dashboard_via_systemd" git clone https://github.com/oraclesorg/eth-netstats cd eth-netstats npm install sudo npm install -g grunt-cli grunt echo "[\"${NETSTATS_SECRET}\"]" > ws_secret.json cd .. sudo bash -c "cat > /etc/systemd/system/oracles-dashboard.service < 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 <