Try new templates

This commit is contained in:
Pavel Khakhulin 2017-10-03 00:18:38 +03:00
parent 6d92e8905b
commit 6cc457f33f
10 changed files with 751 additions and 608 deletions

View File

@ -1,10 +1,10 @@
## DEV Network ## DEV Network
### Mining node ### Mining node
*(Haven't you forgotten to change* `bootnodes`*?)*
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Ftest-templates%2Fdev%2Fdev-mainnet%2Fmining-node%2Ftemplate.json) [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Ftest-templates%2Fdev%2Fdev-mainnet%2Fmining-node%2Ftemplate.json)
### Bootnode ### Bootnode
NOTE: at this moment creating a new bootnode is equivalent to creating a separate network
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Ftest-templates%2Fdev%2Fdev-mainnet%2Fbootnode%2Ftemplate.json) [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foraclesorg%2Ftest-templates%2Fdev%2Fdev-mainnet%2Fbootnode%2Ftemplate.json)
### Netstats server

View File

@ -80,7 +80,7 @@ start_logentries
# */ # */
echo "========== dev/bootnode/install.sh starting ==========" echo "========== dev-mainnet/bootnode/install.sh starting =========="
echo "===== current time: $(date)" echo "===== current time: $(date)"
echo "===== username: $(whoami)" echo "===== username: $(whoami)"
echo "===== working directory: $(pwd)" echo "===== working directory: $(pwd)"
@ -99,40 +99,21 @@ set
echo "===== declare -p:" echo "===== declare -p:"
declare -p declare -p
#echo "===== AFTER SUDO"
#echo "===== SUDO printenv:"
#sudo -u root -E -H bash -c "printenv"
#echo "===== SUDO env:"
#sudo -u root -E -H bash -c "env"
#echo "===== SUDO set:"
#sudo -u root -E -H bash -c "set"
#echo "===== SUDO declare -p:"
#sudo -u root -E -H bash -c "declare -p"
# script parameters
#INSTALL_DOCKER_VERSION="17.03.1~ce-0~ubuntu-xenial"
#INSTALL_DOCKER_IMAGE="parity/parity:v1.6.8"
INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/dev-mainnet/bootnode" INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/dev-mainnet/bootnode"
GENESIS_REPO_LOC="https://raw.githubusercontent.com/oraclesorg/oracles-scripts/master/spec.json" GENESIS_REPO_LOC="https://raw.githubusercontent.com/oraclesorg/oracles-scripts/master/spec.json"
GENESIS_JSON="spec.json" GENESIS_JSON="spec.json"
NODE_TOML="node.toml" NODE_TOML="node.toml"
NODE_PWD="node.pwd"
#echo "===== will use docker version: ${INSTALL_DOCKER_VERSION}"
#echo "===== will use parity docker image: ${INSTALL_DOCKER_IMAGE}"
echo "===== repo base path: ${INSTALL_CONFIG_REPO}" echo "===== repo base path: ${INSTALL_CONFIG_REPO}"
# this should be provided through env by azure template # this should be provided through env by azure template
NETSTATS_SERVER="${NETSTATS_SERVER}"
NETSTATS_SECRET="${NETSTATS_SECRET}" NETSTATS_SECRET="${NETSTATS_SECRET}"
OWNER_KEYFILE="${OWNER_KEYFILE}"
OWNER_KEYPASS="${OWNER_KEYPASS}"
NODE_FULLNAME="${NODE_FULLNAME:-Bootnode}" NODE_FULLNAME="${NODE_FULLNAME:-Bootnode}"
NODE_ADMIN_EMAIL="${NODE_ADMIN_EMAIL:-somebody@somehere}" NODE_ADMIN_EMAIL="${NODE_ADMIN_EMAIL:-somebody@somehere}"
ADMIN_USERNAME="${ADMIN_USERNAME}" ADMIN_USERNAME="${ADMIN_USERNAME}"
#echo "===== HOME before: ${HOME:-NONE}"
export HOME="${HOME:-/home/${ADMIN_USERNAME}}" export HOME="${HOME:-/home/${ADMIN_USERNAME}}"
#echo "===== HOME after: ${HOME}"
prepare_homedir() { prepare_homedir() {
echo "=====> prepare_homedir" echo "=====> prepare_homedir"
@ -144,24 +125,6 @@ prepare_homedir() {
echo "<===== prepare_homedir" echo "<===== prepare_homedir"
} }
add_user_to_docker_group() {
# based on https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo
echo "=====> add_user_to_docker_group"
sudo groupadd docker
#sudo gpasswd -a "${ADMIN_USERNAME}" docker
sudo usermod -aG docker "${ADMIN_USERNAME}"
# based on https://superuser.com/a/345051
#orig_group_id=$(id -gn)
#echo "===== orig_group_id = ${orig_group_id}"
newgrp docker
newgrp -
#newgrp "${orig_group_id}"
echo "===== Groups: "
groups
echo "<===== add_user_to_docker_group"
}
install_ntpd() { install_ntpd() {
echo "=====> install_ntpd" echo "=====> install_ntpd"
sudo timedatectl set-ntp no sudo timedatectl set-ntp no
@ -199,17 +162,6 @@ allocate_swap() {
echo "<===== allocate_swap" echo "<===== allocate_swap"
} }
install_docker_ce() {
echo "=====> install_docker_ce"
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y install docker-ce=${INSTALL_DOCKER_VERSION}
sudo docker pull ${INSTALL_DOCKER_IMAGE}
echo "<===== install_docker_ce"
}
pull_image_and_configs() { pull_image_and_configs() {
echo "=====> pull_image_and_configs" echo "=====> pull_image_and_configs"
# curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}"
@ -221,9 +173,7 @@ pull_image_and_configs() {
logging="engine=trace,network=trace,discovery=trace" logging="engine=trace,network=trace,discovery=trace"
log_file = "/home/${ADMIN_USERNAME}/logs/parity.log" log_file = "/home/${ADMIN_USERNAME}/logs/parity.log"
EOF EOF
echo "${OWNER_KEYPASS}" > "${NODE_PWD}"
mkdir -p parity/keys/OraclesPoA mkdir -p parity/keys/OraclesPoA
echo ${OWNER_KEYFILE} | base64 -d > parity/keys/OraclesPoA/owner.key
echo "<===== pull_image_and_configs" echo "<===== pull_image_and_configs"
} }
@ -271,125 +221,7 @@ EOF"
echo "<===== start_pm2_via_systemd" echo "<===== start_pm2_via_systemd"
} }
install_dashboard() {
echo "=====> install_dashboard"
git clone https://github.com/oraclesorg/eth-netstats
cd eth-netstats
npm install
sudo npm install -g grunt-cli
sudo npm install pm2 -g
grunt
# cat > app.json << EOF
#[
# {
# "name" : "netstats-dashboard",
# "script" : "bin/www",
# "log_date_format" : "YYYY-MM-DD HH:mm:SS Z",
# "error_file" : "/home/${ADMIN_USERNAME}/logs/dashboard.err",
# "out_file" : "/home/${ADMIN_USERNAME}/logs/dashboard.out",
# "merge_logs" : false,
# "watch" : false,
# "max_restarts" : 100,
# "exec_interpreter" : "node",
# "exec_mode" : "fork_mode",
# "env":
# {
# "NODE_ENV" : "production",
# "WS_SECRET" : "${NETSTATS_SECRET}"
# }
# }
#]
#EOF
echo "[\"${NETSTATS_SECRET}\"]" > ws_secret.json
cd ..
sudo apt-get install -y dtach
cat > dashboard.start <<EOF
dtach -n dashboard.dtach bash -c "cd eth-netstats && npm start >> ../logs/dashboard.out 2>> ../logs/dashboard.err"
EOF
chmod +x dashboard.start
./dashboard.start
echo "<====== install_dashboard"
}
install_dashboard_via_systemd() {
echo "=====> install_dashboard_via_systemd"
git clone https://github.com/oraclesorg/eth-netstats
cd eth-netstats
npm install
sudo npm install -g grunt-cli
sudo npm install pm2 -g
grunt
echo "[\"${NETSTATS_SECRET}\"]" > ws_secret.json
cd ..
sudo bash -c "cat > /etc/systemd/system/oracles-dashboard.service <<EOF
[Unit]
Description=oracles dashboard service
After=network.target
[Service]
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}/eth-netstats
Restart=always
ExecStart=/usr/bin/npm start
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-dashboard
sudo systemctl start oracles-dashboard
echo "<====== install_dashboard_via_systemd"
}
# based on https://get.parity.io # based on https://get.parity.io
install_netstats() {
echo "=====> install_netstats"
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 << EOF
[
{
"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
}
}
]
EOF
cd ..
cat > netstats.start <<EOF
cd eth-net-intelligence-api
pm2 startOrRestart app.json
cd ..
EOF
chmod +x netstats.start
./netstats.start
echo "<===== install_netstats"
}
install_netstats_via_systemd() { install_netstats_via_systemd() {
echo "=====> install_netstats_via_systemd" echo "=====> install_netstats_via_systemd"
git clone https://github.com/oraclesorg/eth-net-intelligence-api git clone https://github.com/oraclesorg/eth-net-intelligence-api
@ -419,7 +251,7 @@ install_netstats_via_systemd() {
"LISTENING_PORT" : "30300", "LISTENING_PORT" : "30300",
"INSTANCE_NAME" : "${NODE_FULLNAME}", "INSTANCE_NAME" : "${NODE_FULLNAME}",
"CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}", "CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}",
"WS_SERVER" : "http://localhost:3000", "WS_SERVER" : "http://${NETSTATS_SERVER}:3000",
"WS_SECRET" : "${NETSTATS_SECRET}", "WS_SECRET" : "${NETSTATS_SECRET}",
"VERBOSITY" : 2 "VERBOSITY" : 2
} }
@ -447,173 +279,6 @@ EOF"
echo "<===== install_netstats_via_systemd" echo "<===== install_netstats_via_systemd"
} }
install_chain_explorer() {
echo "=====> install_chain_explorer"
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 <<EOF
var web3 = require('web3');
var net = require('net');
var config = function () {
this.logFormat = "combined";
this.ipcPath = "/home/${ADMIN_USERNAME}/parity/jsonrpc.ipc";
this.provider = new web3.providers.IpcProvider(this.ipcPath, net);
this.bootstrapUrl = "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css";
this.names = {
"0xdd0bb0e2a1594240fed0c2f2c17c1e9ab4f87126": "Bootnode",
};
}
module.exports = config;
EOF
# sudo apt-get install -y dtach
# cat > explorer.start <<EOF
#dtach -n explorer bash -c "cd chain-explorer; PORT=4000 npm start > ../logs/explorer.out 2> ../logs/explorer.err"
#EOF
cat > 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 ..
cat > explorer.start <<EOF
cd chain-explorer
pm2 startOrRestart app.json
cd ..
EOF
chmod +x explorer.start
sudo ./explorer.start
echo "<===== install_chain_explorer"
}
install_chain_explorer_via_systemd() {
echo "=====> 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 <<EOF
var web3 = require('web3');
var net = require('net');
var config = function () {
this.logFormat = "combined";
this.ipcPath = "/home/${ADMIN_USERNAME}/parity/jsonrpc.ipc";
this.provider = new web3.providers.IpcProvider(this.ipcPath, net);
this.bootstrapUrl = "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css";
this.names = {
"0xdd0bb0e2a1594240fed0c2f2c17c1e9ab4f87126": "Bootnode",
};
}
module.exports = config;
EOF
# sudo apt-get install -y dtach
# cat > explorer.start <<EOF
#dtach -n explorer bash -c "cd chain-explorer; PORT=4000 npm start > ../logs/explorer.out 2> ../logs/explorer.err"
#EOF
cat > 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 <<EOF
[Unit]
Description=oracles chain explorer service
After=oracles-pm2.service
[Service]
Type=oneshot
RemainAfterExit=true
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}/chain-explorer
ExecStart=/usr/bin/pm2 startOrRestart app.json
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-chain-explorer
sudo systemctl start oracles-chain-explorer
echo "<===== install_chain_explorer_via_systemd"
}
start_docker() {
echo "=====> start_docker"
cat > docker.start << EOF
sudo docker run -d \\
--name oracles-poa \\
-p 30300:30300 \\
-p 30300:30300/udp \\
-p 8080:8080 \\
-p 8180:8180 \\
-p 8545:8545 \\
-v "$(pwd)/${NODE_PWD}:/build/${NODE_PWD}" \\
-v "$(pwd)/parity:/build/parity" \\
-v "$(pwd)/${GENESIS_JSON}:/build/${GENESIS_JSON}" \\
-v "$(pwd)/${NODE_TOML}:/build/${NODE_TOML}" \\
${INSTALL_DOCKER_IMAGE} -lengine=trace --config "${NODE_TOML}" --ui-no-validation > logs/docker.out 2> logs/docker.err
container_id="\$(cat logs/docker.out)"
sudo ln -sf "/var/lib/docker/containers/\${container_id}/\${container_id}-json.log" logs/parity.log
EOF
chmod +x docker.start
./docker.start
echo "<===== start_docker"
}
use_deb() {
echo "=====> use_deb"
curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb'
sudo dpkg -i parity_1.7.0_amd64.deb
sudo apt-get install dtach
cat > parity.start << EOF
dtach -n parity.dtach bash -c "parity -l engine=trace,discovery=trace,network=trace --config ${NODE_TOML} --ui-no-validation >> logs/parity.out 2>> logs/parity.err"
EOF
chmod +x parity.start
./parity.start
echo "<===== use_deb"
}
use_deb_via_systemd() { use_deb_via_systemd() {
echo "=====> use_deb_via_systemd" echo "=====> use_deb_via_systemd"
curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb' curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb'
@ -640,60 +305,6 @@ EOF"
echo "<===== use_deb_via_systemd" echo "<===== use_deb_via_systemd"
} }
use_bin() {
echo "=====> use_bin"
sudo apt-get install -y dtach unzip
curl -L -o parity-bin-v1.7.0.zip 'https://gitlab.parity.io/parity/parity/-/jobs/61863/artifacts/download'
unzip parity-bin-v1.7.0.zip -d parity-bin-v1.7.0
ln -s parity-bin-v1.7.0/target/release/parity parity-v1.7.0
cat > parity.start << EOF
dtach -n parity.dtach bash -c "./parity-v1.7.0 -l discovery=trace,network=trace --config ${NODE_TOML} --ui-no-validation >> logs/parity.out 2>> logs/parity.err"
EOF
chmod +x parity.start
./parity.start
echo "<===== use_bin"
}
compile_source() {
echo "=====> compile_source"
sudo apt-get -y install gcc g++ libssl-dev libudev-dev pkg-config
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "/home/${ADMIN_USERNAME}/.cargo/env"
rustc --version
cargo --version
git clone -b "v1.7.0" https://github.com/paritytech/parity parity-src-v1.7.0
cd parity-src-v1.7.0
cargo build --release
cd ..
ln -s parity-src-v1.7.0/target/release/parity parity-v1.7.0
cat > parity.start << EOF
./parity-v1.7.0 -l discovery=trace,network=trace --config "${NODE_TOML}" --ui-no-validation >> logs/parity.out 2>> logs/parity.err
EOF
chmod +x parity.start
dtach -n parity.dtach "./parity.start"
echo "<===== compile_source"
}
setup_autoupdate() {
echo "=====> setup_autoupdate"
sudo docker pull oraclesorg/docker-run
sudo bash -c "cat > /etc/cron.daily/docker-autoupdate << EOF
#!/bin/sh
outlog='/home/${ADMIN_USERNAME}/logs/docker-autoupdate.out'
errlog='/home/${ADMIN_USERNAME}/logs/docker-autoupdate.err'
echo \"Starting: \\\$(date)\" >> \"\\\${outlog}\"
echo \"Starting: \\\$(date)\" >> \"\\\${errlog}\"
sudo docker run --rm -v /var/run/docker.sock:/tmp/docker.sock oraclesorg/docker-run update >> \"\\\${outlog}\" 2>> \"\\\${errlog}\"
echo \"\" >> \"\\\${outlog}\"
echo \"\" >> \"\\\${errlog}\"
EOF"
sudo chmod 755 /etc/cron.daily/docker-autoupdate
echo "<===== setup_autoupdate"
}
configure_logrotate() { configure_logrotate() {
echo "=====> configure_logrotate" echo "=====> configure_logrotate"
@ -736,32 +347,18 @@ main () {
sudo apt-get update sudo apt-get update
prepare_homedir prepare_homedir
#add_user_to_docker_group
install_ntpd install_ntpd
install_haveged install_haveged
allocate_swap allocate_swap
install_nodejs install_nodejs
#install_docker_ce
pull_image_and_configs pull_image_and_configs
clone_dapps clone_dapps
#start_docker
#use_deb
use_deb_via_systemd use_deb_via_systemd
#use_bin
#compile_source
#setup_autoupdate
#install_dashboard
install_dashboard_via_systemd
start_pm2_via_systemd start_pm2_via_systemd
#install_netstats
install_netstats_via_systemd install_netstats_via_systemd
#install_chain_explorer
install_chain_explorer_via_systemd
configure_logrotate configure_logrotate
@ -769,4 +366,4 @@ main () {
} }
main main
echo "========== dev/bootnode/install.sh finished ==========" echo "========== dev-mainnet/bootnode/install.sh finished =========="

View File

@ -1,4 +1,4 @@
# dev branch # dev-mainnet branch
[parity] [parity]
chain = "spec.json" chain = "spec.json"
base_path = "parity" base_path = "parity"
@ -26,12 +26,6 @@ cors = "all"
interface = "0.0.0.0" interface = "0.0.0.0"
hosts = ["all"] hosts = ["all"]
port = 8080 port = 8080
[account]
password = ["node.pwd"]
[mining]
force_sealing = true
engine_signer = "0xDd0BB0e2a1594240fED0c2f2c17C1E9AB4F87126"
reseal_on_txs = "none"
[footprint] [footprint]
tracing = "on" tracing = "on"
pruning = "archive" pruning = "archive"

View File

@ -14,18 +14,6 @@
"description": "Node admin email (publicly visible)" "description": "Node admin email (publicly visible)"
} }
}, },
"ownerKeyFile": {
"type": "secureString",
"metadata": {
"description": "Content of the file with mining key (json string)"
}
},
"ownerKeypass": {
"type": "secureString",
"metadata": {
"description": "Password for the mining key"
}
},
"adminUsername": { "adminUsername": {
"type": "string", "type": "string",
"metadata": { "metadata": {
@ -38,10 +26,16 @@
"description": "SSH public key for the Virtual Machine" "description": "SSH public key for the Virtual Machine"
} }
}, },
"netstatsServer": {
"type": "string",
"metadata": {
"description": "NetStats server"
}
},
"netstatsSecret": { "netstatsSecret": {
"type": "secureString", "type": "secureString",
"metadata": { "metadata": {
"description": "NetStats net code" "description": "NetStats secret code"
} }
} }
}, },
@ -62,13 +56,12 @@
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"ubuntuOSVersion": "16.04.0-LTS", "ubuntuOSVersion": "16.04.0-LTS",
"dnsLabelPrefix": "[concat('musereum-bn-', uniqueString(parameters('nodeFullName')))]", "dnsLabelPrefix": "[concat('oracles-bn-', uniqueString(parameters('nodeFullName')))]",
"adminUsername": "[trim(toLower(parameters('adminUsername')))]", "adminUsername": "[trim(toLower(parameters('adminUsername')))]",
"sshPublicKey": "[trim(parameters('sshPublicKey'))]", "sshPublicKey": "[trim(parameters('sshPublicKey'))]",
"nodeFullName": "[trim(parameters('nodeFullName'))]", "nodeFullName": "[trim(parameters('nodeFullName'))]",
"nodeAdminEmail": "[trim(parameters('nodeAdminEmail'))]", "nodeAdminEmail": "[trim(parameters('nodeAdminEmail'))]",
"ownerKeyFile": "[base64(trim(string(parameters('ownerKeyFile'))))]", "netstatsServer": "[trim(parameters('netstatsServer'))]",
"ownerKeypass": "[trim(parameters('ownerKeypass'))]",
"netstatsSecret": "[trim(parameters('netstatsSecret'))]" "netstatsSecret": "[trim(parameters('netstatsSecret'))]"
}, },
"resources": [ "resources": [
@ -226,7 +219,7 @@
] ]
}, },
"protectedSettings": { "protectedSettings": {
"commandToExecute": "[concat('cp install.sh /home/', variables('adminUsername'), '/; cd /home/', variables('adminUsername'), '; chown ', variables('adminUsername'), ':', variables('adminUsername'), ' install.sh; chmod +x install.sh; ADMIN_USERNAME=\"', variables('adminUsername'), '\" NETSTATS_SECRET=\"', variables('netstatsSecret'), '\" OWNER_KEYFILE=\"', variables('ownerKeyFile'), '\" OWNER_KEYPASS=\"', variables('ownerKeypass'), '\" NODE_FULLNAME=\"', variables('nodeFullName'), '\" NODE_ADMIN_EMAIL=\"', variables('nodeAdminEmail'), '\" sudo -u ', variables('adminUsername'), ' -E -H ./install.sh')]" "commandToExecute": "[concat('cp install.sh /home/', variables('adminUsername'), '/; cd /home/', variables('adminUsername'), '; chown ', variables('adminUsername'), ':', variables('adminUsername'), ' install.sh; chmod +x install.sh; ADMIN_USERNAME=\"', variables('adminUsername'), '\" NETSTATS_SERVER=\"', variables('netstatsServer'), '\" NETSTATS_SECRET=\"', variables('netstatsSecret'), '\" NODE_FULLNAME=\"', variables('nodeFullName'), '\" NODE_ADMIN_EMAIL=\"', variables('nodeAdminEmail'), '\" sudo -u ', variables('adminUsername'), ' -E -H ./install.sh')]"
} }
} }
} }

View File

View File

@ -61,7 +61,7 @@ start_logentries
# */ # */
echo "========== dev/mining-node/install.sh starting ==========" echo "========== dev-mainnet/mining-node/install.sh starting =========="
echo "===== current time: $(date)" echo "===== current time: $(date)"
echo "===== username: $(whoami)" echo "===== username: $(whoami)"
echo "===== working directory: $(pwd)" echo "===== working directory: $(pwd)"
@ -74,18 +74,15 @@ echo "===== environmental variables:"
printenv printenv
# script parameters # script parameters
#INSTALL_DOCKER_VERSION="17.03.1~ce-0~ubuntu-xenial"
#INSTALL_DOCKER_IMAGE="parity/parity:v1.6.8"
INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/TestTestNet/mining-node" INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/TestTestNet/mining-node"
GENESIS_REPO_LOC="https://raw.githubusercontent.com/oraclesorg/oracles-scripts/master/spec.json" GENESIS_REPO_LOC="https://raw.githubusercontent.com/oraclesorg/oracles-scripts/master/spec.json"
GENESIS_JSON="spec.json" GENESIS_JSON="spec.json"
NODE_TOML="node.toml" NODE_TOML="node.toml"
NODE_PWD="node.pwd" NODE_PWD="node.pwd"
BOOTNODES_TXT="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/TestTestNet/bootnodes.txt"
export HOME="${HOME:-/home/${ADMIN_USERNAME}}" export HOME="${HOME:-/home/${ADMIN_USERNAME}}"
#echo "===== will use docker version: ${INSTALL_DOCKER_VERSION}"
#echo "===== will use parity docker image: ${INSTALL_DOCKER_IMAGE}"
echo "===== repo base path: ${INSTALL_CONFIG_REPO}" echo "===== repo base path: ${INSTALL_CONFIG_REPO}"
# this should be provided through env by azure template # this should be provided through env by azure template
@ -107,17 +104,6 @@ prepare_homedir() {
echo "<===== prepare_homedir" echo "<===== prepare_homedir"
} }
add_user_to_docker_group() {
# based on https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo
echo "=====> add_user_to_docker_group"
sudo groupadd docker
sudo gpasswd -a "${ADMIN_USERNAME}" docker
newgrp docker
echo "===== Groups: "
groups
echo "<===== add_user_to_docker_group"
}
install_ntpd() { install_ntpd() {
echo "=====> install_ntpd" echo "=====> install_ntpd"
sudo timedatectl set-ntp no sudo timedatectl set-ntp no
@ -167,16 +153,6 @@ install_nodejs() {
echo "<===== install_nodejs" echo "<===== install_nodejs"
} }
install_docker_ce() {
echo "=====> install_docker_ce"
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y install docker-ce=${INSTALL_DOCKER_VERSION}
sudo docker pull ${INSTALL_DOCKER_IMAGE}
echo "<===== install_docker_ce"
}
pull_image_and_configs() { pull_image_and_configs() {
echo "=====> pull_image_and_configs" echo "=====> pull_image_and_configs"
@ -184,7 +160,9 @@ pull_image_and_configs() {
# curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}" # curl -s -O "${INSTALL_CONFIG_REPO}/../${GENESIS_JSON}"
curl -s -o "${GENESIS_JSON}" "${GENESIS_REPO_LOC}" curl -s -o "${GENESIS_JSON}" "${GENESIS_REPO_LOC}"
curl -s -O "${INSTALL_CONFIG_REPO}/${NODE_TOML}" 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 nat=\"extip:${EXT_IP}\"" ${NODE_TOML}
sed -i "/\[network\]/a bootnodes=\[$(cat bootnodes.txt | awk -F'#' '{ print $1 }' | awk '/.+/{ if ($1) print "\""$1"\"" }' | paste -sd "," -)\]" ${NODE_TOML}
cat >> ${NODE_TOML} <<EOF cat >> ${NODE_TOML} <<EOF
[misc] [misc]
logging="engine=trace,network=trace,discovery=trace" logging="engine=trace,network=trace,discovery=trace"
@ -204,53 +182,6 @@ EOF
} }
# based on https://get.parity.io # based on https://get.parity.io
install_netstats() {
echo "=====> install_netstats"
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 ..
cat > netstats.start <<EOF
cd eth-net-intelligence-api
pm2 startOrRestart app.json
cd ..
EOF
chmod +x netstats.start
sudo -u root -E -H ./netstats.start
echo "<===== install_netstats"
}
install_netstats_via_systemd() { install_netstats_via_systemd() {
echo "=====> install_netstats_via_systemd" echo "=====> install_netstats_via_systemd"
git clone https://github.com/oraclesorg/eth-net-intelligence-api git clone https://github.com/oraclesorg/eth-net-intelligence-api
@ -311,43 +242,6 @@ EOF"
echo "<===== install_netstats_via_systemd" echo "<===== install_netstats_via_systemd"
} }
start_docker() {
echo "=====> start_docker"
cat > docker.start <<EOF
sudo docker run -d \\
--name oracles-poa \\
-p 30300:30300 \\
-p 30300:30300/udp \\
-p 8080:8080 \\
-p 8180:8180 \\
-p 8545:8545 \\
-v "$(pwd)/${NODE_PWD}:/build/${NODE_PWD}" \\
-v "$(pwd)/parity:/build/parity" \\
-v "$(pwd)/${GENESIS_JSON}:/build/${GENESIS_JSON}" \\
-v "$(pwd)/${NODE_TOML}:/build/${NODE_TOML}" \\
${INSTALL_DOCKER_IMAGE} --config "${NODE_TOML}" > logs/docker.out 2> logs/docker.err
container_id="\$(cat logs/docker.out)"
sudo ln -sf "/var/lib/docker/containers/\${container_id}/\${container_id}-json.log" logs/parity.log
EOF
chmod +x docker.start
./docker.start
echo "<===== start_docker"
}
use_deb() {
echo "=====> use_deb"
curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb'
sudo dpkg -i parity_1.7.0_amd64.deb
sudo apt-get install dtach
cat > parity.start << EOF
dtach -n parity.dtach bash -c "parity -l engine=trace,discovery=trace,network=trace --config ${NODE_TOML} >> logs/parity.out 2>> logs/parity.err"
EOF
chmod +x parity.start
./parity.start
echo "<===== use_deb"
}
use_deb_via_systemd() { use_deb_via_systemd() {
echo "=====> use_deb_via_systemd" echo "=====> use_deb_via_systemd"
curl -LO 'http://d1h4xl4cr1h0mo.cloudfront.net/nightly/x86_64-unknown-debian-gnu/parity_1.8.0_amd64.deb' curl -LO 'http://d1h4xl4cr1h0mo.cloudfront.net/nightly/x86_64-unknown-debian-gnu/parity_1.8.0_amd64.deb'
@ -373,43 +267,6 @@ EOF"
echo "<===== use_deb_via_systemd" echo "<===== use_deb_via_systemd"
} }
use_bin() {
echo "=====> use_bin"
sudo apt-get install -y dtach unzip
curl -L -o parity-bin-v1.7.0.zip 'https://gitlab.parity.io/parity/parity/-/jobs/61863/artifacts/download'
unzip parity-bin-v1.7.0.zip -d parity-bin-v1.7.0
ln -s parity-bin-v1.7.0/target/release/parity parity-v1.7.0
cat > parity.start << EOF
dtach -n parity.dtach bash -c "./parity-v1.7.0 -l discovery=trace,network=trace --config ${NODE_TOML} >> logs/parity.out 2>> logs/parity.err"
EOF
chmod +x parity.start
./parity.start
echo "<===== use_bin"
}
compile_source() {
echo "=====> compile_source"
sudo apt-get -y install gcc g++ libssl-dev libudev-dev pkg-config
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "/home/${ADMIN_USERNAME}/.cargo/env"
rustc --version
cargo --version
git clone -b "v1.7.0" https://github.com/paritytech/parity parity-src-v1.7.0
cd parity-src-v1.7.0
cargo build --release
cd ..
ln -s parity-src-v1.7.0/target/release/parity parity-v1.7.0
cat > parity.start << EOF
./parity-v1.7.0 -l discovery=trace,network=trace --config "${NODE_TOML}" >> logs/parity.out 2>> logs/parity.err
EOF
chmod +x parity.start
dtach -n parity.dtach "./parity.start"
echo "<===== compile_source"
}
install_scripts() { install_scripts() {
echo "=====> install_scripts" echo "=====> install_scripts"
git clone -b master --single-branch https://github.com/oraclesorg/oracles-scripts git clone -b master --single-branch https://github.com/oraclesorg/oracles-scripts
@ -430,23 +287,6 @@ EOF"
echo "<===== install_scripts" echo "<===== install_scripts"
} }
setup_autoupdate() {
echo "=====> setup_autoupdate"
sudo docker pull oraclesorg/docker-run
sudo bash -c "cat > /etc/cron.daily/docker-autoupdate << EOF
#!/bin/sh
outlog='/home/${ADMIN_USERNAME}/logs/docker-autoupdate.out'
errlog='/home/${ADMIN_USERNAME}/logs/docker-autoupdate.err'
echo \"Starting: \\\$(date)\" >> \"\\\${outlog}\"
echo \"Starting: \\\$(date)\" >> \"\\\${errlog}\"
sudo docker run --rm -v /var/run/docker.sock:/tmp/docker.sock oraclesorg/docker-run update >> \"\\\${outlog}\" 2>> \"\\\${errlog}\"
echo \"\" >> \"\\\${outlog}\"
echo \"\" >> \"\\\${errlog}\"
EOF"
sudo chmod 755 /etc/cron.daily/docker-autoupdate
echo "<===== setup_autoupdate"
}
configure_logrotate() { configure_logrotate() {
echo "=====> configure_logrotate" echo "=====> configure_logrotate"
@ -481,28 +321,20 @@ main () {
sudo apt-get update sudo apt-get update
prepare_homedir prepare_homedir
#add_user_to_docker_group
install_ntpd install_ntpd
install_haveged install_haveged
allocate_swap allocate_swap
install_nodejs install_nodejs
#install_docker_ce
pull_image_and_configs pull_image_and_configs
#start_docker
#use_deb
use_deb_via_systemd use_deb_via_systemd
#use_bin
#setup_autoupdate
#install_netstats
install_netstats_via_systemd install_netstats_via_systemd
install_scripts install_scripts
configure_logrotate configure_logrotate
} }
main main
echo "========== dev/mining-node/install.sh finished ==========" echo "========== dev-mainnet/mining-node/install.sh finished =========="

View File

@ -1,9 +1,8 @@
# dev branch # dev-mainnet branch
[parity] [parity]
chain = "spec.json" chain = "spec.json"
base_path = "parity" base_path = "parity"
[network] [network]
bootnodes=["enode://254f8ff247221e8355d5b5a03ad6523e88de1c89cb21fbb4ed42cc1d58be5f5f917c96b6d0bee69c756168c4e05fce11e68e1f65e8c6fcabd5c5d76763606b24@13.82.111.136:30300"]
port = 30300 port = 30300
discovery=true discovery=true
[rpc] [rpc]

View File

@ -0,0 +1,458 @@
#!/bin/bash
set -e
set -u
set -x
EXT_IP="$(curl ifconfig.co)"
# Install logentries daemon /*
start_logentries() {
echo "=====> start_logentries"
sudo bash -c "echo 'deb http://rep.logentries.com/ trusty main' > /etc/apt/sources.list.d/logentries.list"
sudo bash -c "gpg --keyserver pgp.mit.edu --recv-keys C43C79AD && gpg -a --export C43C79AD | apt-key add -"
sudo apt-get update
sudo apt-get install -y logentries
sudo le reinit --user-key=0665901a-e843-41c5-82c1-2cc4b39f0b21 --pull-server-side-config=False
mkdir -p /home/${ADMIN_USERNAME}/logs
touch /home/${ADMIN_USERNAME}/logs/dashboard.err
touch /home/${ADMIN_USERNAME}/logs/dashboard.out
touch /home/${ADMIN_USERNAME}/logs/parity.log
touch /home/${ADMIN_USERNAME}/logs/netstats_daemon.err
touch /home/${ADMIN_USERNAME}/logs/netstats_daemon.out
touch /home/${ADMIN_USERNAME}/logs/explorer.err
touch /home/${ADMIN_USERNAME}/logs/explorer.out
touch /home/${ADMIN_USERNAME}/logs/parity.err
touch /home/${ADMIN_USERNAME}/logs/parity.out
sudo bash -c "cat >> /etc/le/config << EOF
[install_err]
path = /var/lib/waagent/custom-script/download/0/stderr
destination = dev-mainnet/${EXT_IP}
[install_out]
path = /var/lib/waagent/custom-script/download/0/stdout
destination = dev-mainnet/${EXT_IP}
[dashboard_err]
path = /home/${ADMIN_USERNAME}/logs/dashboard.err
destination = dev-mainnet/${EXT_IP}
[dashboard_out]
path = /home/${ADMIN_USERNAME}/logs/dashboard.out
destination = dev-mainnet/${EXT_IP}
[parity_log]
path = /home/${ADMIN_USERNAME}/logs/parity.log
destination = dev-mainnet/${EXT_IP}
[netstats_daemon_err]
path = /home/${ADMIN_USERNAME}/logs/netstats_daemon.err
destination = dev-mainnet/${EXT_IP}
[netstats_daemon_out]
path = /home/${ADMIN_USERNAME}/logs/netstats_daemon.out
destination = dev-mainnet/${EXT_IP}
[explorer_err]
path = /home/${ADMIN_USERNAME}/logs/explorer.err
destination = dev-mainnet/${EXT_IP}
[explorer_out]
path = /home/${ADMIN_USERNAME}/logs/explorer.out
destination = dev-mainnet/${EXT_IP}
[parity_err]
path = /home/${ADMIN_USERNAME}/logs/parity.err
destination = dev-mainnet/${EXT_IP}
[parity_out]
path = /home/${ADMIN_USERNAME}/logs/parity.out
destination = dev-mainnet/${EXT_IP}
EOF"
sudo apt-get install -y logentries-daemon
sudo service logentries start
echo "<===== start_logentries"
}
start_logentries
# */
echo "========== dev-mainnet/netstat-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 "===== external ip: ${EXT_IP}"
echo "===== printenv:"
printenv
echo "===== env:"
env
echo "===== set:"
set
echo "===== declare -p:"
declare -p
INSTALL_CONFIG_REPO="https://raw.githubusercontent.com/oraclesorg/test-templates/dev/dev-mainnet/bootnode"
GENESIS_REPO_LOC="https://raw.githubusercontent.com/oraclesorg/oracles-scripts/master/spec.json"
GENESIS_JSON="spec.json"
NODE_TOML="node.toml"
NODE_PWD="node.pwd"
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}}"
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"
}
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}"
curl -s -o "${GENESIS_JSON}" "${GENESIS_REPO_LOC}"
curl -s -O "${INSTALL_CONFIG_REPO}/${NODE_TOML}"
sed -i "/\[network\]/a nat=\"extip:${EXT_IP}\"" ${NODE_TOML}
cat >> ${NODE_TOML} <<EOF
[misc]
logging="engine=trace,network=trace,discovery=trace"
log_file = "/home/${ADMIN_USERNAME}/logs/parity.log"
EOF
mkdir -p parity/keys/OraclesPoA
echo "<===== pull_image_and_configs"
}
clone_dapps() {
echo "=====> clone_dapps"
mkdir -p parity/dapps
git clone https://github.com/oraclesorg/oracles-dapps-keys-generation.git parity/dapps/KeysGenerator
git clone https://github.com/oraclesorg/oracles-dapps-voting.git parity/dapps/Voting
git clone https://github.com/oraclesorg/oracles-dapps-validators.git parity/dapps/ValidatorsList
echo "<===== clone_dapps"
}
install_nodejs() {
echo "=====> install_nodejs"
# curl -sL https://deb.nodesource.com/setup_0.12 | bash -
curl -sL https://deb.nodesource.com/setup_6.x | 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 bash -c "cat > /etc/systemd/system/oracles-pm2.service <<EOF
[Unit]
Description=oracles pm2 service
After=network.target
[Service]
Type=oneshot
RemainAfterExit=true
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}
ExecStart=/usr/bin/pm2 ping
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-pm2
sudo systemctl start oracles-pm2
echo "<===== start_pm2_via_systemd"
}
install_dashboard_via_systemd() {
echo "=====> install_dashboard_via_systemd"
git clone https://github.com/oraclesorg/eth-netstats
cd eth-netstats
npm install
sudo npm install -g grunt-cli
sudo npm install pm2 -g
grunt
echo "[\"${NETSTATS_SECRET}\"]" > ws_secret.json
cd ..
sudo bash -c "cat > /etc/systemd/system/oracles-dashboard.service <<EOF
[Unit]
Description=oracles dashboard service
After=network.target
[Service]
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}/eth-netstats
Restart=always
ExecStart=/usr/bin/npm start
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-dashboard
sudo systemctl start oracles-dashboard
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 <<EOF
[Unit]
Description=oracles netstats service
After=oracles-pm2.service
[Service]
Type=oneshot
RemainAfterExit=true
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}/eth-net-intelligence-api
ExecStart=/usr/bin/pm2 startOrRestart app.json
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-netstats
sudo systemctl start oracles-netstats
echo "<===== install_netstats_via_systemd"
}
install_chain_explorer_via_systemd() {
echo "=====> 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 <<EOF
var web3 = require('web3');
var net = require('net');
var config = function () {
this.logFormat = "combined";
this.ipcPath = "/home/${ADMIN_USERNAME}/parity/jsonrpc.ipc";
this.provider = new web3.providers.IpcProvider(this.ipcPath, net);
this.bootstrapUrl = "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css";
this.names = {
"0xdd0bb0e2a1594240fed0c2f2c17c1e9ab4f87126": "Bootnode",
};
}
module.exports = config;
EOF
cat > 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 <<EOF
[Unit]
Description=oracles chain explorer service
After=oracles-pm2.service
[Service]
Type=oneshot
RemainAfterExit=true
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
Environment=MYVAR=myval
WorkingDirectory=/home/${ADMIN_USERNAME}/chain-explorer
ExecStart=/usr/bin/pm2 startOrRestart app.json
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-chain-explorer
sudo systemctl start oracles-chain-explorer
echo "<===== install_chain_explorer_via_systemd"
}
use_deb_via_systemd() {
echo "=====> use_deb_via_systemd"
curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb'
sudo dpkg -i parity_1.7.0_amd64.deb
#curl -LO 'http://d1h4xl4cr1h0mo.cloudfront.net/nightly/x86_64-unknown-debian-gnu/parity_1.8.0_amd64.deb'
#sudo dpkg -i parity_1.8.0_amd64.deb
sudo bash -c "cat > /etc/systemd/system/oracles-parity.service <<EOF
[Unit]
Description=oracles parity service
After=network.target
[Service]
User=${ADMIN_USERNAME}
Group=${ADMIN_USERNAME}
WorkingDirectory=/home/${ADMIN_USERNAME}
ExecStart=/usr/bin/parity --config=node.toml --ui-no-validation
Restart=always
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable oracles-parity
sudo systemctl start oracles-parity
echo "<===== use_deb_via_systemd"
}
configure_logrotate() {
echo "=====> configure_logrotate"
sudo bash -c "cat > /etc/logrotate.d/oracles.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"
echo "<===== configure_logrotate"
}
# MAIN
main () {
sudo apt-get update
prepare_homedir
install_ntpd
install_haveged
allocate_swap
install_nodejs
pull_image_and_configs
clone_dapps
use_deb_via_systemd
install_dashboard_via_systemd
start_pm2_via_systemd
install_netstats_via_systemd
install_chain_explorer_via_systemd
configure_logrotate
download_initial_keys_script
}
main
echo "========== dev-mainnet/netstats-server/install.sh finished =========="

View File

@ -0,0 +1,38 @@
# dev-mainnet branch
[parity]
chain = "spec.json"
base_path = "parity"
[network]
port = 30300
discovery=true
[rpc]
cors = "all"
interface = "all"
hosts = ["all"]
port = 8545
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]
[ui]
interface = "0.0.0.0"
port = 8180
[websockets]
disable = false
port = 8546
interface = "all"
origins = ["all"]
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
hosts = ["all"]
[dapps]
cors = "all"
interface = "0.0.0.0"
hosts = ["all"]
port = 8080
[account]
password = ["node.pwd"]
[mining]
force_sealing = true
engine_signer = "0xDd0BB0e2a1594240fED0c2f2c17C1E9AB4F87126"
reseal_on_txs = "none"
[footprint]
tracing = "on"
pruning = "archive"
fat_db = "on"

View File

@ -0,0 +1,232 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"nodeFullName": {
"type": "string",
"metadata": {
"description": "Node full name (publicly visible)"
}
},
"nodeAdminEmail": {
"type": "string",
"metadata": {
"description": "Node admin email (publicly visible)"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine"
}
},
"sshPublicKey": {
"type": "string",
"metadata": {
"description": "SSH public key for the Virtual Machine"
}
},
"netstatsSecret": {
"type": "secureString",
"metadata": {
"description": "NetStats net code"
}
}
},
"variables": {
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'salinuxvm')]",
"imagePublisher": "Canonical",
"imageOffer": "UbuntuServer",
"nicName": "myVMNic",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"storageAccountType": "Standard_LRS",
"publicIPAddressName": "myPublicIP",
"publicIPAddressType": "Static",
"vmName": "MyUbuntuVM",
"vmSize": "Standard_A1",
"virtualNetworkName": "MyVNET",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"ubuntuOSVersion": "16.04.0-LTS",
"dnsLabelPrefix": "[concat('musereum-bn-', uniqueString(parameters('nodeFullName')))]",
"adminUsername": "[trim(toLower(parameters('adminUsername')))]",
"sshPublicKey": "[trim(parameters('sshPublicKey'))]",
"nodeFullName": "[trim(parameters('nodeFullName'))]",
"nodeAdminEmail": "[trim(parameters('nodeAdminEmail'))]",
"netstatsSecret": "[trim(parameters('netstatsSecret'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2017-06-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
},
{
"apiVersion": "2017-04-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[variables('dnsLabelPrefix')]"
}
}
},
{
"apiVersion": "2017-04-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"apiVersion": "2017-04-01",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[variables('adminUsername')]",
"adminPassword": "",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', variables('adminUsername'), '/.ssh/authorized_keys')]",
"keyData": "[variables('sshPublicKey')]"
}
]
}
}
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks": [
{
"diskSizeGB": "128",
"lun": 0,
"createOption": "Empty"
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2016-01-01').primaryEndpoints.blob)]"
}
}
},
"resources": [
{
"apiVersion": "2015-06-15",
"type": "extensions",
"name": "config-app",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"tags": {
"displayName": "config-app"
},
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"https://raw.githubusercontent.com/oraclesorg/test-templates/dev/dev-mainnet/bootnode/install.sh"
]
},
"protectedSettings": {
"commandToExecute": "[concat('cp install.sh /home/', variables('adminUsername'), '/; cd /home/', variables('adminUsername'), '; chown ', variables('adminUsername'), ':', variables('adminUsername'), ' install.sh; chmod +x install.sh; ADMIN_USERNAME=\"', variables('adminUsername'), '\" NETSTATS_SECRET=\"', variables('netstatsSecret'), '\" NODE_FULLNAME=\"', variables('nodeFullName'), '\" NODE_ADMIN_EMAIL=\"', variables('nodeAdminEmail'), '\" sudo -u ', variables('adminUsername'), ' -E -H ./install.sh')]"
}
}
}
]
}
],
"outputs": {
"hostname": {
"type": "string",
"value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]"
},
"sshCommand": {
"type": "string",
"value": "[concat('ssh ', variables('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]"
}
}
}