diff --git a/TestTestNet/bootnode/install.sh b/TestTestNet/bootnode/install.sh index 5ca7589..6846893 100644 --- a/TestTestNet/bootnode/install.sh +++ b/TestTestNet/bootnode/install.sh @@ -42,15 +42,9 @@ ADMIN_USERNAME="${ADMIN_USERNAME}" export HOME="${HOME:-/home/${ADMIN_USERNAME}}" -prepare_homedir() { - echo "=====> prepare_homedir" - # ln -s "$(pwd)" "/home/${ADMIN_USERNAME}/script-dir" - cd "/home/${ADMIN_USERNAME}" - echo "Now changed directory to: $(pwd)" - mkdir -p logs - mkdir -p logs/old - echo "<===== prepare_homedir" -} +echo "===== downloading common.funcs" +curl -sLO "https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/common.funcs" +source common.funcs setup_ufw() { echo "=====> setup_ufw" @@ -64,48 +58,6 @@ setup_ufw() { echo "<===== setup_ufw" } -increase_ulimit_n() { - echo "${ADMIN_USERNAME} soft nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null - echo "${ADMIN_USERNAME} hard nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null -} - -install_ntpd() { - echo "=====> install_ntpd" - sudo timedatectl set-ntp no - sudo apt-get -y install ntp - - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF -#!/bin/sh -sudo service ntp stop -sudo ntpdate -s ntp.ubuntu.com -sudo service ntp start -EOF" - sudo chmod 755 /etc/cron.hourly/ntpdate - echo "<===== install_ntpd" -} - -install_haveged() { - echo "=====> install_haveged" - sudo apt-get -y install haveged - sudo update-rc.d haveged defaults - echo "<===== install_haveged" -} - -allocate_swap() { - echo "=====> allocate_swap" - sudo apt-get -y install bc - #sudo fallocate -l $(echo "$(free -b | awk '/Mem/{ print $2 }')*2" | bc -l) /swapfile - sudo fallocate -l 1G /swapfile - sudo chmod 600 /swapfile - sudo mkswap /swapfile - sudo swapon /swapfile - sudo sh -c "printf '/swapfile none swap sw 0 0\n' >> /etc/fstab" - sudo sh -c "printf 'vm.swappiness=10\n' >> /etc/sysctl.conf" - sudo sysctl vm.vfs_cache_pressure=50 - sudo sh -c "printf 'vm.vfs_cache_pressure = 50\n' >> /etc/sysctl.conf" - echo "<===== allocate_swap" -} - pull_image_and_configs() { echo "=====> pull_image_and_configs" # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" @@ -133,180 +85,6 @@ clone_dapps() { echo "<===== clone_dapps" } -install_nodejs() { - echo "=====> install_nodejs" - curl -sL ${NODE_SOURCE_DEB} | sudo -E bash - - sudo apt-get update - sudo apt-get install -y build-essential git unzip wget nodejs ntp cloud-utils - - # add symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - echo "<===== install_nodejs" -} - -start_pm2_via_systemd() { - echo "=====> start_pm2_via_systemd" - sudo npm install pm2 -g - sudo bash -c "cat > /etc/systemd/system/oracles-pm2.service < install_netstats_via_systemd" - git clone https://github.com/oraclesorg/eth-net-intelligence-api - cd eth-net-intelligence-api - #sed -i '/"web3"/c "web3": "0.19.x",' package.json - npm install - - cat > app.json << EOL -[ - { - "name" : "netstats_daemon", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", - "error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err", - "out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 100, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30300", - "INSTANCE_NAME" : "${NODE_FULLNAME}", - "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", - "WS_SERVER" : "http://${NETSTATS_SERVER}:3000", - "WS_SECRET" : "${NETSTATS_SECRET}", - "VERBOSITY" : 2 - } - } -] -EOL - cd .. - sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service < use_deb_via_systemd" - curl -LO "${PARITY_DEB_LOC}" - sudo dpkg -i "$(basename ${PARITY_DEB_LOC})" - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < use_bin_via_systemd" - curl -o parity -L "${PARITY_BIN_LOC}" - chmod +x parity - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y libstdc++6 - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < configure_logrotate" - - sudo bash -c "cat > /home/${ADMIN_USERNAME}/oracles-logrotate.conf << EOF -/home/${ADMIN_USERNAME}/logs/*.log { - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s - olddir old -} - -/home/${ADMIN_USERNAME}/.pm2/pm2.log { - su ${ADMIN_USERNAME} ${ADMIN_USERNAME} - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s -} -EOF" - - sudo bash -c "cat > /etc/cron.hourly/oracles-logrotate < gen_certs" mkdir certs diff --git a/TestTestNet/common.funcs b/TestTestNet/common.funcs new file mode 100644 index 0000000..34f6d90 --- /dev/null +++ b/TestTestNet/common.funcs @@ -0,0 +1,225 @@ +prepare_homedir() { + echo "=====> prepare_homedir" + # ln -s "$(pwd)" "/home/${ADMIN_USERNAME}/script-dir" + cd "/home/${ADMIN_USERNAME}" + echo "Now changed directory to: $(pwd)" + mkdir -p logs + mkdir -p logs/old + echo "<===== prepare_homedir" +} + +increase_ulimit_n() { + echo "${ADMIN_USERNAME} soft nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null + echo "${ADMIN_USERNAME} hard nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null +} + +install_ntpd() { + echo "=====> install_ntpd" + sudo timedatectl set-ntp no + sudo apt-get -y install ntp + + sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF +#!/bin/sh +sudo service ntp stop +sudo ntpdate -s ntp.ubuntu.com +sudo service ntp start +EOF" + sudo chmod 755 /etc/cron.hourly/ntpdate + echo "<===== install_ntpd" +} + +install_haveged() { + echo "=====> install_haveged" + sudo apt-get -y install haveged + sudo update-rc.d haveged defaults + echo "<===== install_haveged" +} + +allocate_swap() { + echo "=====> allocate_swap" + sudo apt-get -y install bc + #sudo fallocate -l $(echo "$(free -b | awk '/Mem/{ print $2 }')*2" | bc -l) /swapfile + sudo fallocate -l 1G /swapfile + sudo chmod 600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + sudo sh -c "printf '/swapfile none swap sw 0 0\n' >> /etc/fstab" + sudo sh -c "printf 'vm.swappiness=10\n' >> /etc/sysctl.conf" + sudo sysctl vm.vfs_cache_pressure=50 + sudo sh -c "printf 'vm.vfs_cache_pressure = 50\n' >> /etc/sysctl.conf" + echo "<===== allocate_swap" +} + +install_nodejs() { + echo "=====> install_nodejs" + curl -sL ${NODE_SOURCE_DEB} | sudo -E bash - + sudo apt-get update + sudo apt-get install -y build-essential git unzip wget nodejs ntp cloud-utils + + # add symlink if it doesn't exist + [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node + echo "<===== install_nodejs" +} + +start_pm2_via_systemd() { + echo "=====> start_pm2_via_systemd" + sudo npm install pm2 -g + sudo bash -c "cat > /etc/systemd/system/oracles-pm2.service < install_netstats_via_systemd" + git clone https://github.com/oraclesorg/eth-net-intelligence-api + cd eth-net-intelligence-api + #sed -i '/"web3"/c "web3": "0.19.x",' package.json + npm install + + cat > app.json << EOL +[ + { + "name" : "netstats_daemon", + "script" : "app.js", + "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", + "error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err", + "out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out", + "merge_logs" : false, + "watch" : false, + "max_restarts" : 100, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "RPC_HOST" : "localhost", + "RPC_PORT" : "8545", + "LISTENING_PORT" : "30300", + "INSTANCE_NAME" : "${NODE_FULLNAME}", + "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", + "WS_SERVER" : "http://${NETSTATS_SERVER}:3000", + "WS_SECRET" : "${NETSTATS_SECRET}", + "VERBOSITY" : 2 + } + } +] +EOL + cd .. + sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service < use_deb_via_systemd" + curl -LO "${PARITY_DEB_LOC}" + sudo dpkg -i "$(basename ${PARITY_DEB_LOC})" + sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < use_bin_via_systemd" + curl -o parity -L "${PARITY_BIN_LOC}" + chmod +x parity + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install -y libstdc++6 + sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < configure_logrotate" + + sudo bash -c "cat > /home/${ADMIN_USERNAME}/oracles-logrotate.conf << EOF +/home/${ADMIN_USERNAME}/logs/*.log { + rotate 10 + size 200M + missingok + compress + copytruncate + dateext + dateformat %Y-%m-%d-%s + olddir old +} + +/home/${ADMIN_USERNAME}/.pm2/pm2.log { + su ${ADMIN_USERNAME} ${ADMIN_USERNAME} + rotate 10 + size 200M + missingok + compress + copytruncate + dateext + dateformat %Y-%m-%d-%s +} +EOF" + + sudo bash -c "cat > /etc/cron.hourly/oracles-logrotate < prepare_homedir" - #ln -s "$(pwd)" "/home/${ADMIN_USERNAME}/script-dir" - cd "/home/${ADMIN_USERNAME}" - mkdir -p logs - mkdir -p logs/old - echo "<===== prepare_homedir" -} +export HOME="${HOME:-/home/${ADMIN_USERNAME}}" + +echo "===== downloading common.funcs" +curl -sLO "https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/common.funcs" +source common.funcs set_ssh_keys() { echo "=====> set_ssh_keys" @@ -81,61 +76,6 @@ setup_ufw() { echo "<===== setup_ufw" } -increase_ulimit_n() { - echo "=====> increase_ulimit_n" - echo "${ADMIN_USERNAME} soft nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null - echo "${ADMIN_USERNAME} hard nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null - echo "<===== increase_ulimit_n" -} - -install_ntpd() { - echo "=====> install_ntpd" - sudo timedatectl set-ntp no - sudo apt-get -y install ntp - - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF -#!/bin/sh -sudo service ntp stop -sudo ntpdate -s ntp.ubuntu.com -sudo service ntp start -EOF" - sudo chmod 755 /etc/cron.hourly/ntpdate - echo "<===== install_ntpd" -} - -install_haveged() { - echo "=====> install_haveged" - sudo apt-get -y install haveged - sudo update-rc.d haveged defaults - echo "<===== install_haveged" -} - -allocate_swap() { - echo "=====> allocate_swap" - sudo apt-get -y install bc - #sudo fallocate -l $(echo "$(free -b | awk '/Mem/{ print $2 }')*2" | bc -l) /swapfile - sudo fallocate -l 1G /swapfile - sudo chmod 600 /swapfile - sudo mkswap /swapfile - sudo swapon /swapfile - sudo sh -c "printf '/swapfile none swap sw 0 0\n' >> /etc/fstab" - sudo sh -c "printf 'vm.swappiness=10\n' >> /etc/sysctl.conf" - sudo sysctl vm.vfs_cache_pressure=50 - sudo sh -c "printf 'vm.vfs_cache_pressure = 50\n' >> /etc/sysctl.conf" - echo "<===== allocate_swap" -} - -install_nodejs() { - echo "=====> install_nodejs" - curl -sL ${NODE_SOURCE_DEB} | sudo -E bash - - sudo apt-get update - sudo apt-get install -y build-essential git unzip wget nodejs ntp cloud-utils - - # add symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - echo "<===== install_nodejs" -} - pull_image_and_configs() { echo "=====> pull_image_and_configs" @@ -163,140 +103,6 @@ EOF echo "<===== pull_image_and_configs" } -start_pm2_via_systemd() { - echo "=====> start_pm2_via_systemd" - sudo npm install pm2 -g - sudo bash -c "cat > /etc/systemd/system/oracles-pm2.service < install_netstats_via_systemd" - git clone https://github.com/oraclesorg/eth-net-intelligence-api - cd eth-net-intelligence-api - #sed -i '/"web3"/c "web3": "0.19.x",' package.json - npm install - sudo npm install pm2 -g - - cat > app.json << EOL -[ - { - "name" : "netstats_daemon", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", - "error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err", - "out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 100, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30300", - "INSTANCE_NAME" : "${NODE_FULLNAME}", - "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", - "WS_SERVER" : "http://${NETSTATS_SERVER}:3000", - "WS_SECRET" : "${NETSTATS_SECRET}", - "VERBOSITY" : 2 - } - } -] -EOL - cd .. - sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service < use_deb_via_systemd" - curl -LO "${PARITY_DEB_LOC}" - sudo dpkg -i "$(basename ${PARITY_DEB_LOC})" - - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < use_bin_via_systemd" - curl -o parity -L "${PARITY_BIN_LOC}" - chmod +x parity - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y libstdc++6 - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < install_scripts" git clone -b ${SCRIPTS_BRANCH} --single-branch https://github.com/oraclesorg/oracles-scripts @@ -317,42 +123,6 @@ EOF" echo "<===== install_scripts" } -configure_logrotate() { - echo "=====> configure_logrotate" - - sudo bash -c "cat > /home/${ADMIN_USERNAME}/oracles-logrotate.conf << EOF -/home/${ADMIN_USERNAME}/logs/*.log { - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s - olddir old -} - -/home/${ADMIN_USERNAME}/.pm2/pm2.log { - su ${ADMIN_USERNAME} ${ADMIN_USERNAME} - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s -} -EOF" - - sudo bash -c "cat > /etc/cron.hourly/oracles-logrotate < prepare_homedir" - # ln -s "$(pwd)" "/home/${ADMIN_USERNAME}/script-dir" - cd "/home/${ADMIN_USERNAME}" - echo "Now changed directory to: $(pwd)" - mkdir -p logs - mkdir -p logs/old - echo "<===== prepare_homedir" -} - -increase_ulimit_n() { - echo "${ADMIN_USERNAME} soft nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null - echo "${ADMIN_USERNAME} hard nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null -} +echo "===== downloading common.funcs" +curl -sLO "https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/common.funcs" +source common.funcs setup_ufw() { echo "=====> setup_ufw" @@ -64,43 +54,6 @@ setup_ufw() { echo "<===== setup_ufw" } -install_ntpd() { - echo "=====> install_ntpd" - sudo timedatectl set-ntp no - sudo apt-get -y install ntp - - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF -#!/bin/sh -sudo service ntp stop -sudo ntpdate -s ntp.ubuntu.com -sudo service ntp start -EOF" - sudo chmod 755 /etc/cron.hourly/ntpdate - echo "<===== install_ntpd" -} - -install_haveged() { - echo "=====> install_haveged" - sudo apt-get -y install haveged - sudo update-rc.d haveged defaults - echo "<===== install_haveged" -} - -allocate_swap() { - echo "=====> allocate_swap" - sudo apt-get -y install bc - #sudo fallocate -l $(echo "$(free -b | awk '/Mem/{ print $2 }')*2" | bc -l) /swapfile - sudo fallocate -l 1G /swapfile - sudo chmod 600 /swapfile - sudo mkswap /swapfile - sudo swapon /swapfile - sudo sh -c "printf '/swapfile none swap sw 0 0\n' >> /etc/fstab" - sudo sh -c "printf 'vm.swappiness=10\n' >> /etc/sysctl.conf" - sudo sysctl vm.vfs_cache_pressure=50 - sudo sh -c "printf 'vm.vfs_cache_pressure = 50\n' >> /etc/sysctl.conf" - echo "<===== allocate_swap" -} - pull_image_and_configs() { echo "=====> pull_image_and_configs" # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" @@ -119,41 +72,6 @@ EOF echo "<===== pull_image_and_configs" } -install_nodejs() { - echo "=====> install_nodejs" - # curl -sL https://deb.nodesource.com/setup_0.12 | bash - - curl -sL ${NODE_SOURCE_DEB} | sudo -E bash - - sudo apt-get update - sudo apt-get install -y build-essential git unzip wget nodejs ntp cloud-utils - - # add symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - echo "<===== install_nodejs" -} - -start_pm2_via_systemd() { - sudo npm install pm2 -g - echo "=====> start_pm2_via_systemd" - sudo bash -c "cat > /etc/systemd/system/oracles-pm2.service < install_dashboard_via_systemd" git clone https://github.com/oraclesorg/eth-netstats @@ -183,64 +101,6 @@ EOF" echo "<====== install_dashboard_via_systemd" } -# based on https://get.parity.io -install_netstats_via_systemd() { - echo "=====> install_netstats_via_systemd" - git clone https://github.com/oraclesorg/eth-net-intelligence-api - cd eth-net-intelligence-api - #sed -i '/"web3"/c "web3": "0.19.x",' package.json - npm install - sudo npm install pm2 -g - - cat > app.json << EOL -[ - { - "name" : "netstats_daemon", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", - "error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err", - "out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 100, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30300", - "INSTANCE_NAME" : "${NODE_FULLNAME}", - "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", - "WS_SERVER" : "http://localhost:3000", - "WS_SECRET" : "${NETSTATS_SECRET}", - "VERBOSITY" : 2 - } - } -] -EOL - cd .. - sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service < install_chain_explorer_via_systemd" git clone https://github.com/oraclesorg/chain-explorer @@ -307,90 +167,6 @@ EOF" echo "<===== install_chain_explorer_via_systemd" } -use_deb_via_systemd() { - echo "=====> use_deb_via_systemd" - curl -LO "${PARITY_DEB_LOC}" - sudo dpkg -i "$(basename ${PARITY_DEB_LOC})" - - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < configure_logrotate" - - sudo bash -c "cat > /home/${ADMIN_USERNAME}/oracles-logrotate.conf << EOF -/home/${ADMIN_USERNAME}/logs/*.log { - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s - olddir old -} - -/home/${ADMIN_USERNAME}/.pm2/pm2.log { - su ${ADMIN_USERNAME} ${ADMIN_USERNAME} - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s -} -EOF" - - sudo bash -c "cat > /etc/cron.hourly/oracles-logrotate < use_bin_via_systemd" - curl -o parity -L "${PARITY_BIN_LOC}" - chmod +x parity - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y libstdc++6 - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < prepare_homedir" - # ln -s "$(pwd)" "/home/${ADMIN_USERNAME}/script-dir" - cd "/home/${ADMIN_USERNAME}" - echo "Now changed directory to: $(pwd)" - mkdir -p logs - mkdir -p logs/old - echo "<===== prepare_homedir" -} +export HOME="${HOME:-/home/${ADMIN_USERNAME}}" + +echo "===== downloading common.funcs" +curl -sLO "https://raw.githubusercontent.com/oraclesorg/test-templates/${TEMPLATES_BRANCH}/common.funcs" +source common.funcs setup_ufw() { echo "=====> setup_ufw" @@ -62,48 +56,6 @@ setup_ufw() { echo "<===== setup_ufw" } -increase_ulimit_n() { - echo "${ADMIN_USERNAME} soft nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null - echo "${ADMIN_USERNAME} hard nofile 100000" | sudo tee /etc/security/limits.conf >> /dev/null -} - -install_ntpd() { - echo "=====> install_ntpd" - sudo timedatectl set-ntp no - sudo apt-get -y install ntp - - sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF -#!/bin/sh -sudo service ntp stop -sudo ntpdate -s ntp.ubuntu.com -sudo service ntp start -EOF" - sudo chmod 755 /etc/cron.hourly/ntpdate - echo "<===== install_ntpd" -} - -install_haveged() { - echo "=====> install_haveged" - sudo apt-get -y install haveged - sudo update-rc.d haveged defaults - echo "<===== install_haveged" -} - -allocate_swap() { - echo "=====> allocate_swap" - sudo apt-get -y install bc - #sudo fallocate -l $(echo "$(free -b | awk '/Mem/{ print $2 }')*2" | bc -l) /swapfile - sudo fallocate -l 1G /swapfile - sudo chmod 600 /swapfile - sudo mkswap /swapfile - sudo swapon /swapfile - sudo sh -c "printf '/swapfile none swap sw 0 0\n' >> /etc/fstab" - sudo sh -c "printf 'vm.swappiness=10\n' >> /etc/sysctl.conf" - sudo sysctl vm.vfs_cache_pressure=50 - sudo sh -c "printf 'vm.vfs_cache_pressure = 50\n' >> /etc/sysctl.conf" - echo "<===== allocate_swap" -} - pull_image_and_configs() { echo "=====> pull_image_and_configs" # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" @@ -118,7 +70,7 @@ pull_image_and_configs() { log_file = "/home/${ADMIN_USERNAME}/logs/parity.log" [account] password = ["${NODE_PWD}"] -unlock = ["${MINING_ADDRESS}"] +unlock = ["${OWNER_ADDRESS}"] [mining] force_sealing = true engine_signer = "${OWNER_ADDRESS}" @@ -131,181 +83,6 @@ EOF echo "<===== pull_image_and_configs" } -install_nodejs() { - echo "=====> install_nodejs" - curl -sL ${NODE_SOURCE_DEB} | sudo -E bash - - sudo apt-get update - sudo apt-get install -y build-essential git unzip wget nodejs ntp cloud-utils - - # add symlink if it doesn't exist - [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node - echo "<===== install_nodejs" -} - -start_pm2_via_systemd() { - echo "=====> start_pm2_via_systemd" - sudo npm install pm2 -g - sudo bash -c "cat > /etc/systemd/system/oracles-pm2.service < install_netstats_via_systemd" - git clone https://github.com/oraclesorg/eth-net-intelligence-api - cd eth-net-intelligence-api - #sed -i '/"web3"/c "web3": "0.19.x",' package.json - npm install - sudo npm install pm2 -g - - cat > app.json << EOL -[ - { - "name" : "netstats_daemon", - "script" : "app.js", - "log_date_format" : "YYYY-MM-DD HH:mm:SS Z", - "error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err", - "out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out", - "merge_logs" : false, - "watch" : false, - "max_restarts" : 100, - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8545", - "LISTENING_PORT" : "30300", - "INSTANCE_NAME" : "${NODE_FULLNAME}", - "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", - "WS_SERVER" : "http://${NETSTATS_SERVER}:3000", - "WS_SECRET" : "${NETSTATS_SECRET}", - "VERBOSITY" : 2 - } - } -] -EOL - cd .. - sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service < use_deb_via_systemd" - curl -LO "${PARITY_DEB_LOC}" - sudo dpkg -i "$(basename ${PARITY_DEB_LOC})" - - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < use_bin_via_systemd" - curl -o parity -L "${PARITY_BIN_LOC}" - chmod +x parity - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y libstdc++6 - sudo bash -c "cat > /etc/systemd/system/oracles-parity.service < configure_logrotate" - - sudo bash -c "cat > /home/${ADMIN_USERNAME}/oracles-logrotate.conf << EOF -/home/${ADMIN_USERNAME}/logs/*.log { - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s - olddir old -} - -/home/${ADMIN_USERNAME}/.pm2/pm2.log { - su ${ADMIN_USERNAME} ${ADMIN_USERNAME} - rotate 10 - size 200M - missingok - compress - copytruncate - dateext - dateformat %Y-%m-%d-%s -} -EOF" - - sudo bash -c "cat > /etc/cron.hourly/oracles-logrotate < download_initial_keys_script" git clone -b ${IKEYS_BRANCH} --single-branch https://github.com/oraclesorg/oracles-initial-keys