Try add explorer server templates
This commit is contained in:
parent
5197471809
commit
033dae4f5d
|
@ -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)
|
||||
|
|
|
@ -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} <<EOF
|
||||
[misc]
|
||||
log_file = "/home/${ADMIN_USERNAME}/logs/parity.log"
|
||||
EOF
|
||||
mkdir -p parity_data/keys/OraclesPoA
|
||||
|
||||
echo "<===== pull_image_and_configs"
|
||||
}
|
||||
|
||||
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_data/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 = {
|
||||
"${OWNER_ADDRESS}": "Master of Ceremony",
|
||||
};
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
# MAIN
|
||||
main () {
|
||||
sudo apt-get update
|
||||
|
||||
prepare_homedir
|
||||
setup_ufw
|
||||
increase_ulimit_n
|
||||
install_ntpd
|
||||
install_haveged
|
||||
allocate_swap
|
||||
|
||||
install_nodejs
|
||||
pull_image_and_configs
|
||||
|
||||
if [ "${PARITY_INSTALLATION_MODE}" = "BIN" ]; then
|
||||
use_bin_via_systemd
|
||||
elif [ "${PARITY_INSTALLATION_MODE}" = "DEB" ]; then
|
||||
use_deb_via_systemd
|
||||
else
|
||||
echo "===== invalid PARITY_INSTALLATION_MODE == ${PARITY_INSTALLATION_MODE}. Should be either BIN or DEB"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start_pm2_via_systemd
|
||||
|
||||
install_chain_explorer_via_systemd
|
||||
|
||||
configure_logrotate
|
||||
}
|
||||
|
||||
main
|
||||
echo "========== ${TEMPLATES_BRANCH}/explorer/install.sh finished =========="
|
|
@ -0,0 +1,9 @@
|
|||
[parity]
|
||||
chain = "spec.json"
|
||||
base_path = "parity_data"
|
||||
[network]
|
||||
port = 30303
|
||||
[footprint]
|
||||
tracing = "on"
|
||||
pruning = "archive"
|
||||
fat_db = "on"
|
|
@ -0,0 +1,350 @@
|
|||
{
|
||||
"$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"
|
||||
}
|
||||
},
|
||||
"vmSize": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "VM Resources"
|
||||
},
|
||||
"defaultValue": "Standard_A4m_v2",
|
||||
"allowedValues": [
|
||||
"Standard_A1_v2",
|
||||
"Standard_A2_v2",
|
||||
"Standard_A4_v2",
|
||||
"Standard_A8_v2",
|
||||
"Standard_A2m_v2",
|
||||
"Standard_A4m_v2",
|
||||
"Standard_A8m_v2"
|
||||
]
|
||||
},
|
||||
"sshPublicKey": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "SSH public key for the Virtual Machine"
|
||||
}
|
||||
},
|
||||
},
|
||||
"variables": {
|
||||
"TEMPLATES_BRANCH": "dev-mainnet",
|
||||
"MAIN_REPO_FETCH": "oraclesorg",
|
||||
"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": "[parameters('vmSize')]",
|
||||
"virtualNetworkName": "MyVNET",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
|
||||
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
|
||||
"ubuntuOSVersion": "16.04.0-LTS",
|
||||
"dnsLabelPrefix": "[concat('oracles-ns-', uniqueString(resourceGroup().id, parameters('nodeFullName')))]",
|
||||
"adminUsername": "[trim(toLower(parameters('adminUsername')))]",
|
||||
"sshPublicKey": "[trim(parameters('sshPublicKey'))]",
|
||||
"nodeFullName": "[trim(parameters('nodeFullName'))]",
|
||||
"nodeAdminEmail": "[trim(parameters('nodeAdminEmail'))]",
|
||||
"networkSecurityGroupName": "OraclesTest-NSG-1"
|
||||
},
|
||||
"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/networkSecurityGroups/', variables('networkSecurityGroupName'))]",
|
||||
"[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')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"networkSecurityGroup": {
|
||||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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": [
|
||||
"[concat('https://raw.githubusercontent.com/',variables('MAIN_REPO_FETCH'),'/deployment-azure/', variables('TEMPLATES_BRANCH'), '/nodes/explorer/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; TEMPLATES_BRANCH=\"', variables('TEMPLATES_BRANCH'), '\" ADMIN_USERNAME=\"', variables('adminUsername'), '\" NODE_FULLNAME=\"', variables('nodeFullName'), '\" NODE_ADMIN_EMAIL=\"', variables('nodeAdminEmail'),'\" MAIN_REPO_FETCH=\"', variables('MAIN_REPO_FETCH'), '\" sudo -u ', variables('adminUsername'), ' -E -H ./install.sh')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "[variables('networkSecurityGroupName')]",
|
||||
"type": "Microsoft.Network/networkSecurityGroups",
|
||||
"apiVersion": "2016-09-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"comments": "Network Security Group (NSG) for your Primary NIC",
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{
|
||||
"name": "allow-ssh",
|
||||
"properties": {
|
||||
"priority": 1000,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "Tcp",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "22"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "allow-rpc",
|
||||
"properties": {
|
||||
"priority": 1100,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "Tcp",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "8545"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "allow-discovery",
|
||||
"properties": {
|
||||
"priority": 1200,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "*",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "30303"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "allow-https",
|
||||
"properties": {
|
||||
"priority": 1300,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "*",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "443"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "access-dashboard",
|
||||
"properties": {
|
||||
"priority": 1400,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "Tcp",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "3000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "access-explorer",
|
||||
"properties": {
|
||||
"priority": 1500,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "Tcp",
|
||||
"access": "Allow",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "4000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "disallow-other",
|
||||
"properties": {
|
||||
"priority": 2000,
|
||||
"direction": "Inbound",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"protocol": "*",
|
||||
"access": "Deny",
|
||||
"destinationAddressPrefix": "*",
|
||||
"destinationPortRange": "*"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"hostname": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]"
|
||||
},
|
||||
"sshCommand": {
|
||||
"type": "string",
|
||||
"value": "[concat('ssh ', variables('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue