diff --git a/moin-on-ubuntu/README.md b/moin-on-ubuntu/README.md new file mode 100644 index 000000000000..a8ab291bc520 --- /dev/null +++ b/moin-on-ubuntu/README.md @@ -0,0 +1,24 @@ +# MOIN Public Blockchain Node + +This Microsoft Azure template deploys a single MOIN client which will connect to the public MOIN network. + + + + +# Template Parameters + +When you click the Deploy to Azure icon above, you need to specify the following template parameters: + +* `adminUsername`: This is the account for connecting to your MOIN host. +* `adminPassword`: This is your password for the host. Azure requires passwords to have One upper case, one lower case, a special character, and a number. +* `dnsLabelPrefix`: This is used as both the VM name and DNS name of your public IP address. Please ensure an unique name. +* `installMethod`: This tells Azure how to install the software. The default is using the Binaries. You may choose to install from Source, but be advised this method takes substantially longer to complete. +* `vmSize`: This is the size of the VM to use. Recommendations: Use the A series for Binaries installs, and D series for installations from Source. + +# Getting Started Tutorial + +* Click the `Deploy to Azure` icon above +* Complete the template parameters, choose your resource group, accept the terms and click Create +* Wait about 15 minutes for the VM to spin up and install the software +* Connect to the VM via SSH using the DNS name assigned to your Public IP +* If you wish to launch MOIN run 'moind' diff --git a/moin-on-ubuntu/azuredeploy.json b/moin-on-ubuntu/azuredeploy.json new file mode 100644 index 000000000000..985ae5b30eb0 --- /dev/null +++ b/moin-on-ubuntu/azuredeploy.json @@ -0,0 +1,210 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "adminUsername": { + "type": "string", + "metadata": { + "description": "Username for the Virtual Machine." + } + }, + "adminPassword": { + "type": "securestring", + "metadata": { + "description": "Password for the Virtual Machine." + } + }, + "dnsLabelPrefix": { + "type": "string", + "metadata": { + "description": "Hostname assigned to the Public IP, also used as the VM Name. Must be lowercase. It should match with the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$ or it will raise an error." + } + }, + "installMethod": { + "type": "string", + "defaultValue": "From_Binaries", + "allowedValues": [ + "From_Binaries", + "From_Source" + ], + "metadata": { + "description": "Method to install MOIN. From_Binaries: Official binaries + blockchain. From_Source: official MOIN repo on GitHub." + } + }, + "vmSize": { + "type": "string", + "defaultValue": "Standard_A1", + "allowedValues": [ + "Standard_A1", + "Standard_A2", + "Standard_A3", + "Standard_D1", + "Standard_D2", + "Standard_D3" + ], + "metadata": { + "description": "Size of VM" + } + } + }, + "variables": { + "imagePublisher": "Canonical", + "imageOffer": "UbuntuServer", + "OSDiskName": "MOINOSDisk", + "imageSKU": "14.04.4-LTS", + "nicName": "MOINNic", + "addressPrefix": "10.0.0.0/16", + "subnetName": "MOINSubnet", + "subnetPrefix": "10.0.0.0/24", + "storageAccountType": "Standard_LRS", + "storageAccountName": "[concat(uniquestring(resourceGroup().id, 'MOIN'))]", + "publicIPAddressName": "MOINPublicIP", + "publicIPAddressType": "Dynamic", + "vmStorageAccountContainerName": "vhds", + "vmName": "[parameters('dnsLabelPrefix')]", + "virtualNetworkName": "MOINVNET", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "apiVersion": "2015-06-15" + }, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "name": "[variables('storageAccountName')]", + "apiVersion": "[variables('apiVersion')]", + "location": "[resourceGroup().location]", + "properties": { + "accountType": "[variables('storageAccountType')]" + } + }, + { + "apiVersion": "[variables('apiVersion')]", + "type": "Microsoft.Network/publicIPAddresses", + "name": "[variables('publicIPAddressName')]", + "location": "[resourceGroup().location]", + "properties": { + "publicIPAllocationMethod": "[variables('publicIPAddressType')]", + "dnsSettings": { + "domainNameLabel": "[parameters('dnsLabelPrefix')]" + } + } + }, + { + "apiVersion": "[variables('apiVersion')]", + "type": "Microsoft.Network/virtualNetworks", + "name": "[variables('virtualNetworkName')]", + "location": "[resourceGroup().location]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetPrefix')]" + } + } + ] + } + }, + { + "apiVersion": "[variables('apiVersion')]", + "type": "Microsoft.Network/networkInterfaces", + "name": "[variables('nicName')]", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('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": "[variables('apiVersion')]", + "type": "Microsoft.Compute/virtualMachines", + "name": "[variables('vmName')]", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "properties": { + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "osProfile": { + "computerName": "[variables('vmName')]", + "adminUsername": "[parameters('adminUsername')]", + "adminPassword": "[parameters('adminPassword')]" + }, + "storageProfile": { + "imageReference": { + "publisher": "[variables('imagePublisher')]", + "offer": "[variables('imageOffer')]", + "sku": "[variables('imageSKU')]", + "version": "latest" + }, + "osDisk": { + "name": "osdisk", + "vhd": { + "uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]" + }, + "caching": "ReadWrite", + "createOption": "FromImage" + } + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" + } + ] + }, + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": "true", + "storageUri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net')]" + } + } + } + }, + { + "type": "Microsoft.Compute/virtualMachines/extensions", + "name": "[concat(variables('vmName'),'/newuserscript')]", + "location": "[resourceGroup().location]", + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]" + ], + "properties": { + "publisher": "Microsoft.OSTCExtensions", + "type": "CustomScriptForLinux", + "typeHandlerVersion": "1.4", + "autoUpgradeMinorVersion": true, + "settings": { + "fileUris": [ + "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/moin-on-ubuntu/build_moin.sh" + ], + "commandToExecute": "[concat('sh build_moin.sh ', parameters('installMethod'), ' ', parameters('adminUsername'))]" + } + } + } + ] +} diff --git a/moin-on-ubuntu/azuredeploy.parameters.json b/moin-on-ubuntu/azuredeploy.parameters.json new file mode 100644 index 000000000000..bf95681a5be3 --- /dev/null +++ b/moin-on-ubuntu/azuredeploy.parameters.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "dnsLabelPrefix": { + "value": "GEN-UNIQUE-11" + }, + "adminUsername": { + "value": "azureuser" + }, + "adminPassword": { + "value": "GEN-PASSWORD" + }, + "installMethod": { + "value": "From_Source" + }, + "vmSize": { + "value": "Standard_A1" + } + } +} diff --git a/moin-on-ubuntu/build_moin.sh b/moin-on-ubuntu/build_moin.sh new file mode 100644 index 000000000000..e68e7a45b91d --- /dev/null +++ b/moin-on-ubuntu/build_moin.sh @@ -0,0 +1,64 @@ +#!/bin/bash +set -x + +echo "initializing MOIN installation" + +date +ps axjf + +AZUREUSER=$2 +HOMEDIR="/home/$AZUREUSER" +MOINPATH="$HOMEDIR/.moin" +VMNAME=`hostname` +echo "User: $AZUREUSER" +echo "User home dir: $HOMEDIR" +echo "User MOIN path: $MOINPATH" +echo "vmname: $VMNAME" + + +if [ $1 = 'From_Source' ]; then +## Compile from Source +sudo apt-get update +sudo apt-get -y install git build-essential libssl-dev libdb-dev libdb++-dev libboost-all-dev libqrencode-dev unzip pwgen +cd /usr/local/src/ +sudo git clone https://github.com/MOIN/moin +cd moin/src +sudo make -f makefile.unix + +sudo cp moind /usr/bin/moind + +else +## Download Binaries +sudo apt-get update +sudo apt-get -y install git build-essential libssl-dev libdb-dev libdb++-dev libboost-all-dev libqrencode-dev unzip pwgen +cd /usr/local/src/ +DOWNLOADFILE=$(curl -s https://api.github.com/repos/MOIN/MOIN/releases | grep browser_download_url | grep linux64 | head -n 1 | cut -d '"' -f 4) +DOWNLOADNAME=$(curl -s https://api.github.com/repos/MOIN/MOIN/releases | grep name | grep linux64 | head -n 1 | cut -d '"' -f 4) +sudo wget $DOWNLOADFILE +sudo unzip $DOWNLOADNAME +sudo cp moind /usr/bin/moind +fi + +# Create Client Directory +if [ ! -e "$MOINPATH" ] +then + su - $AZUREUSER -c "mkdir $MOINPATH" +fi + +# Download Blockchain +su - $AZUREUSER -c "cd $MOINPATH; wget https://github.com/MOIN/blockchain/releases/download/latest/blockchain.zip" +su - $AZUREUSER -c "cd $MOINPATH; unzip blockchain.zip" + +# Create configuration File +su - $AZUREUSER -c "touch $MOINPATH/moin.conf" +rpcu=$(pwgen -ncsB 35 1) +rpcp=$(pwgen -ncsB 75 1) +echo "rpcuser="$rpcu" +rpcpassword="$rpcp" +daemon=1" > $MOINPATH/moin.conf + +# Start MOIN Client +su - $AZUREUSER -c "moind" + +echo "completed MOIN install $$" +exit 0 diff --git a/moin-on-ubuntu/metadata.json b/moin-on-ubuntu/metadata.json new file mode 100644 index 000000000000..fdb66485caca --- /dev/null +++ b/moin-on-ubuntu/metadata.json @@ -0,0 +1,7 @@ +{ + "itemDisplayName": "MOIN on Ubuntu", + "description": "MOIN is a project dedicated to the exploration of cutting-edge decentralized technologies with a peer-to-peer electronic cash system at its core.", + "summary": "Deploy MOIN on Ubuntu to access services running on the blockchain", + "githubUsername": "KingCaper", + "dateUpdated": "2016-03-28" +}