├── rds ├── list-rds-instances.sh ├── delete-omnidb-instance.sh ├── create-omnidb-instance.sh ├── waitForDBAvailable.groovy ├── createDBInstance.groovy └── waitForDBAvailableViaSDK.groovy ├── .gitignore ├── tools ├── omni_aws_box_src │ └── metadata.json ├── omni-aws.box ├── getBlockCountFromOmniDB.sh ├── getBlockCount.sh ├── make-omni-aws-vagrant-box.sh └── associateAddress.groovy ├── synced └── README.md ├── omniengine-synced ├── bitcoin.conf ├── pip.packages ├── sql.conf └── install-prerequisites.sh ├── omniwallet-synced ├── bitcoin.conf ├── sql.conf ├── res │ ├── mtools-snapshot.7z.asc │ ├── app.sh │ └── install-sx.sh └── install-omni.sh ├── install-mastercoin-base-root.sh ├── .gitattributes ├── mastercore-synced ├── install-prerequisites.sh └── openssl.cnf ├── setup-omni-template.sh ├── setup-omni-fromvagrant.sh ├── install-omniwallet-user.sh ├── install-omniengine-user.sh ├── clone-build-install-bitcoind.sh ├── DefaultVagrantConfig.rb ├── adoc └── jenkins.adoc ├── Vagrantfile └── README.md /rds/list-rds-instances.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rds-describe-db-instances 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | setup-omni-private.sh 3 | LocalVagrantConfig.rb 4 | -------------------------------------------------------------------------------- /tools/omni_aws_box_src/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "provider": "aws" 3 | } 4 | -------------------------------------------------------------------------------- /tools/omni-aws.box: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmniLayer/omni-devops/HEAD/tools/omni-aws.box -------------------------------------------------------------------------------- /synced/README.md: -------------------------------------------------------------------------------- 1 | # Default Vagrant Sync directory 2 | 3 | Currently empty and used by the `empty` VM. 4 | 5 | -------------------------------------------------------------------------------- /rds/delete-omnidb-instance.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rds-delete-db-instance $OMNI_DB_INSTANCE --skip-final-snapshot --force 3 | -------------------------------------------------------------------------------- /omniengine-synced/bitcoin.conf: -------------------------------------------------------------------------------- 1 | rpcuser=username 2 | rpcpassword=passgoeshere 3 | rpcconnect=host.yourdomain.com 4 | rpcssl=1 5 | 6 | -------------------------------------------------------------------------------- /omniwallet-synced/bitcoin.conf: -------------------------------------------------------------------------------- 1 | rpcuser=username 2 | rpcpassword=passgoeshere 3 | rpcconnect=host.yourdomain.com 4 | rpcssl=1 5 | 6 | -------------------------------------------------------------------------------- /tools/getBlockCountFromOmniDB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | psql omniwallet < ~/.bitcoin/bitcoin.conf 27 | 28 | sed -e "s#^\(sqluser=\)\(.*\)#\1${PGUSER}#" \ 29 | -e "s#^\(sqlpassword=\)\(.*\)#\1${PGPASSWORD}#" \ 30 | -e "s#^\(sqlconnect=\)\(.*\)#\1${PGHOST}#" \ 31 | -e "s#^\(sqlport=\)\(.*\)#\1${PGPORT}#" \ 32 | /vagrant/sql.conf > ~/.omni/sql.conf 33 | -------------------------------------------------------------------------------- /mastercore-synced/openssl.cnf: -------------------------------------------------------------------------------- 1 | #-------------openssl.cnf---------------- 2 | [ req ] 3 | default_bits = 1024 # Size of keys 4 | default_keyfile = key.pem # name of generated keys 5 | default_md = md5 # message digest algorithm 6 | string_mask = nombstr # permitted characters 7 | distinguished_name = req_distinguished_name 8 | 9 | [ req_distinguished_name ] 10 | # Variable name Prompt string 11 | 0.organizationName = Organization Name (company) 12 | organizationalUnitName = Organizational Unit Name (department, division) 13 | emailAddress = Email Address 14 | emailAddress_max = 40 15 | localityName = Locality Name (city, district) 16 | stateOrProvinceName = State or Province Name (full name) 17 | countryName = Country Name (2 letter code) 18 | countryName_min = 2 19 | countryName_max = 2 20 | commonName = Common Name (hostname, IP, or your name) 21 | commonName_max = 64 22 | 23 | 24 | #-------------------Edit this section------------------------------ 25 | countryName_default = US 26 | stateOrProvinceName_default = CA 27 | localityName_default = San Francisco 28 | 0.organizationName_default = example_company 29 | organizationalUnitName_default = Information Systems 30 | commonName_default = server_name 31 | emailAddress_default = admin@example.com 32 | -------------------------------------------------------------------------------- /install-omniengine-user.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | #REPOURL="https://github.com/mastercoin-MSC/omniEngine.git" 4 | #BRANCH="master" 5 | REPOURL=$1 6 | BRANCH=$2 7 | REPODIR="omniEngine" 8 | BTCRPC_CONNECT=$3 9 | BTCRPC_USER=$4 10 | BTCRPC_PASSWORD=$5 11 | BTCRPC_SSL=$6 12 | PGHOST=$7 13 | PGUSER=$8 14 | PGPASSWORD=$9 15 | PGPORT=$10 16 | 17 | 18 | # Install RPMs, python packages, etc. 19 | cd /vagrant 20 | ./install-prerequisites.sh 21 | cd 22 | 23 | # Clone and checkout using passed (usually from Vagrant) parameters 24 | git clone --no-checkout $REPOURL $REPODIR 25 | cd $REPODIR 26 | git checkout $BRANCH 27 | 28 | mkdir -p logs 29 | 30 | mkdir -p ~/.omni 31 | mkdir -p ~/.bitcoin 32 | 33 | #cp /vagrant/bitcoin.conf ~/.bitcoin/bitcoin.conf 34 | #cp /vagrant/sql.conf ~/.omni 35 | sed -e "s#^\(rpcuser=\)\(.*\)#\1${BTCRPC_USER}#" \ 36 | -e "s#^\(rpcpassword=\)\(.*\)#\1${BTCRPC_PASSWORD}#" \ 37 | -e "s#^\(rpcconnect=\)\(.*\)#\1${BTCRPC_CONNECT}#" \ 38 | -e "s#^\(rpcssl=\)\(.*\)#\1${BTCRPC_SSL}#" \ 39 | /vagrant/bitcoin.conf > ~/.bitcoin/bitcoin.conf 40 | 41 | sed -e "s#^\(sqluser=\)\(.*\)#\1${PGUSER}#" \ 42 | -e "s#^\(sqlpassword=\)\(.*\)#\1${PGPASSWORD}#" \ 43 | -e "s#^\(sqlconnect=\)\(.*\)#\1${PGHOST}#" \ 44 | -e "s#^\(sqlport=\)\(.*\)#\1${PGPORT}#" \ 45 | /vagrant/sql.conf > ~/.omni/sql.conf 46 | 47 | python install/installOmniEngineCronJob.py 48 | 49 | 50 | -------------------------------------------------------------------------------- /tools/associateAddress.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Grab(group='com.amazonaws', module='aws-java-sdk', version='1.8.7') 3 | import com.amazonaws.services.ec2.AmazonEC2Client 4 | import com.amazonaws.auth.profile.ProfileCredentialsProvider 5 | import com.amazonaws.auth.EnvironmentVariableCredentialsProvider 6 | import com.amazonaws.services.ec2.model.DescribeInstancesRequest 7 | import com.amazonaws.services.ec2.model.AssociateAddressRequest 8 | import com.amazonaws.regions.Region 9 | import com.amazonaws.regions.Regions 10 | import groovy.json.JsonSlurper 11 | 12 | def credentials = new EnvironmentVariableCredentialsProvider().getCredentials() 13 | 14 | if (args.size() != 2) { println "Usage: associateAddress.groovy
" ; System.exit(-1) } 15 | def machineName = args[0] 16 | def address = args[1] 17 | def json = "vagrant awsinfo -p -m ${machineName}".execute().text 18 | def info = new JsonSlurper().parseText(json) 19 | def instanceId = info.instance_id 20 | 21 | //"ec2-associate-address -i ${instanceId} ${address} --region us-west-2".execute().waitForProcessOutput(System.out, System.err) 22 | 23 | 24 | println "Creating ec2 client..." 25 | def ec2 = new AmazonEC2Client(credentials) 26 | ec2.region = Region.getRegion(Regions.US_WEST_2) 27 | 28 | println "Creating and sending AssociateAddressRequest..." 29 | def req = new AssociateAddressRequest(instanceId, address) 30 | def result = ec2.associateAddress(req) 31 | 32 | println "Result: ${result}" 33 | 34 | 35 | -------------------------------------------------------------------------------- /clone-build-install-bitcoind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | REPOURL=$1 4 | BRANCH=$2 5 | REPODIR=$3 6 | BTCRPC_CONNECT=$4 7 | BTCRPC_USER=$5 8 | BTCRPC_PASSWORD=$6 9 | BTCRPC_SSL=$7 10 | BTCRPC_ALLOWIP=$8 11 | USERNAME=`whoami` 12 | BTCDIR="/var/lib/bitcoind" 13 | 14 | # Clone and checkout using passed (usually from Vagrant) parameters 15 | git clone --no-checkout $REPOURL $REPODIR 16 | cd $REPODIR 17 | git checkout $BRANCH 18 | 19 | # Build bitcoind (Master Core) 20 | 21 | ./autogen.sh 22 | ./configure 23 | make 24 | 25 | # Install as an Upstart service 26 | sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh 27 | 28 | # Put the vagrant user (usually 'vagrant' or 'ubuntu') in the bitcoin group 29 | # so that /etc/bitcoin/bitcoin.conf can be seen by bitcoin-cli/mastercore-cli 30 | sudo usermod -a -G bitcoin $USERNAME 31 | 32 | if [ $BTCRPC_SSL == "1" ] ; then 33 | echo "Creating self-signed SSL certificate..." 34 | # cd /var/lib/bitcoind 35 | sudo openssl genrsa -out "${BTCDIR}/server.pem" 2048 36 | sudo openssl req -new -x509 -nodes -sha1 -days 3650 -key "${BTCDIR}/server.pem" -batch -config /vagrant/openssl.cnf -out "${BTCDIR}/server.cert" 37 | fi 38 | 39 | sudo sed -i.bak -e "s#^.\(rpcuser=\)\(.*\)#\1${BTCRPC_USER}#" \ 40 | -e "s#^.\(rpcpassword=\)\(.*\)#\1${BTCRPC_PASSWORD}#" \ 41 | -e "s#^.\(rpcssl=\)\(.*\)#\1${BTCRPC_SSL}#" \ 42 | -e "s#^.\(rpcallowip=\)\(.*\)#\1${BTCRPC_ALLOWIP}#" \ 43 | /etc/bitcoin/bitcoin.conf 44 | 45 | sudo service mastercored start 46 | -------------------------------------------------------------------------------- /rds/waitForDBAvailable.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | Integer sleepMillis = 60*1000 // 1 minute 3 | Integer timeOut = 60*sleepMillis // 1 hour 4 | Integer timeWaited = 0 5 | String instanceId 6 | 7 | if (args.size() == 0) { 8 | instanceId = System.getenv("OMNI_DB_INSTANCE") 9 | if (instanceId == null) { 10 | println "OMNI_DB_INSTANCE env var must be defined or instanceId specified as command argument" 11 | } 12 | } else if (args.size() == 1) { 13 | instanceId = args[0] 14 | } else { 15 | println "Usage: waitForDBAvailable.groovy [instanceId]" 16 | System.exit(-1) 17 | } 18 | println "Waiting for instance ${instanceId} to be 'available'..." 19 | String instanceStatus 20 | while (true) { 21 | instanceStatus = getStatus(instanceId) 22 | println "Status is: ${instanceStatus}" 23 | if (instanceStatus == 'available') { 24 | break 25 | } else if (timeWaited > timeOut ) { 26 | println "Timeout" 27 | System.exit(-1) 28 | } 29 | sleep sleepMillis 30 | timeWaited += sleepMillis 31 | } 32 | 33 | String getStatus(String instanceId) { 34 | String command="rds-describe-db-instances ${instanceId} --show-xml" 35 | String xml = command.execute().text 36 | def DescribeDBInstancesResponse = new XmlParser().parseText(xml) 37 | def instance = DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances.DBInstance[0] 38 | if (instance == null) throw new Exception("No DB instance exists for id '${instanceId}'") 39 | String status = DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances.DBInstance[0].DBInstanceStatus.text() 40 | return status 41 | } 42 | -------------------------------------------------------------------------------- /rds/createDBInstance.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Grab(group='com.amazonaws', module='aws-java-sdk', version='1.8.7') 3 | import com.amazonaws.services.rds.AmazonRDSClient 4 | import com.amazonaws.auth.EnvironmentVariableCredentialsProvider 5 | import com.amazonaws.regions.Region 6 | import com.amazonaws.regions.Regions 7 | import com.amazonaws.services.rds.model.CreateDBInstanceRequest 8 | 9 | String instanceID = System.getenv("OMNI_DB_INSTANCE") 10 | String securityGID = System.getenv("OMNI_DB_SEC_GID") 11 | String username = System.getenv("PGUSER") 12 | String password = System.getenv("PGPASSWORD") 13 | 14 | def client = new RDSClient() 15 | client.createDBInstance(instanceID, securityGID, username, password, true) 16 | 17 | class RDSClient { 18 | private AmazonRDSClient rds 19 | 20 | public RDSClient() { 21 | def credentials = new EnvironmentVariableCredentialsProvider().getCredentials() 22 | println "Creating RDS client..." 23 | rds = new AmazonRDSClient(credentials) 24 | rds.region = Region.getRegion(Regions.US_WEST_2) 25 | } 26 | 27 | public createDBInstance(String instanceID, String securityGID, String username, String password, Boolean publicIP) { 28 | def req = new CreateDBInstanceRequest() 29 | .withDBInstanceIdentifier(instanceID) 30 | .withEngine("postgres") 31 | .withEngineVersion("9.3.3") 32 | .withDBInstanceClass("db.t2.micro") 33 | .withAllocatedStorage(5) 34 | .withPubliclyAccessible(publicIP) 35 | .withVpcSecurityGroupIds(securityGID) 36 | .withBackupRetentionPeriod(0) 37 | .withMasterUsername(username) 38 | .withMasterUserPassword(password) 39 | 40 | def result = rds.createDBInstance(req) 41 | println result 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /DefaultVagrantConfig.rb: -------------------------------------------------------------------------------- 1 | # 2 | # DefaultVagrantConfig.rb 3 | # 4 | # This file is required by the omni-devops Vagrantfile to initialize settings 5 | # 6 | # DO NOT CHANGE THIS FILE DIRECTLY! 7 | # 8 | # To Override settings copy to LocalVagrantConfig.rb and modify variables as needed 9 | # 10 | 11 | # Standard AWS Settings 12 | AWS_ACCESS_KEY="setme" 13 | AWS_SECRET_KEY="setme" 14 | AWS_KEYPAIR_NAME="setme" 15 | AWS_SSH_KEY_PATH="/path/to/key.pem" 16 | AWS_DEFAULT_REGION="us-west-2" 17 | AWS_CREDENTIAL_FILE="/path/to/rds-credentials.txt" 18 | 19 | # 20 | # Configure Git Repository and Branch for Omniwallet 21 | # 22 | OMNIWALLET_GIT_REPO="https://github.com/mastercoin-MSC/omniwallet.git" 23 | OMNIWALLET_GIT_BRANCH="master" 24 | 25 | # 26 | # Configure Git Repository and Branch for OmniEngine 27 | # 28 | OMNIENGINE_GIT_REPO="https://github.com/mastercoin-MSC/omniEngine.git" 29 | OMNIENGINE_GIT_BRANCH="master" 30 | 31 | # 32 | # Configure Git Repository and Branch for Master Core build from source 33 | # omnicore-master is the latest (most) stable branch of Master Core with 34 | # necessary devops additions -- currently based on mscore-0.0.8 branch. 35 | # 36 | MASTERCORE_GIT_REPO="https://github.com/msgilligan/mastercore.git" 37 | MASTERCORE_GIT_BRANCH="omnicore-master" 38 | 39 | # Standard PostgreSQL Settings 40 | PGUSER="setme" 41 | PGPASSWORD="setme" 42 | PGHOST="setme" 43 | PGPORT="5432" 44 | 45 | # Amazon RDS DB Settings 46 | OMNI_DB_INSTANCE="instance-id-goes-here" 47 | OMNI_DB_SEC_GID="security group id to assign your RDS instance goes here" 48 | 49 | # Username/Password for 'omniengine' and 'omniwww' database users 50 | OMNIDB_ENGINE_USER="omniengine" 51 | OMNIDB_ENGINE_PASSWORD="setme" 52 | OMNIDB_WWW_USER="omniwww" 53 | OMNIDB_WWW_PASSWORD="setme" 54 | 55 | # Bitcoind/Mastercored settings 56 | BTCRPC_CONNECT="setme" 57 | BTCRPC_USER="setme" 58 | BTCRPC_PASSWORD="setme" 59 | BTCRPC_SSL="1" 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /rds/waitForDBAvailableViaSDK.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Grab(group='com.amazonaws', module='aws-java-sdk', version='1.8.7') 3 | import com.amazonaws.services.rds.AmazonRDSClient 4 | import com.amazonaws.auth.EnvironmentVariableCredentialsProvider 5 | import com.amazonaws.services.rds.model.DescribeDBInstancesRequest 6 | import com.amazonaws.regions.Region 7 | import com.amazonaws.regions.Regions 8 | 9 | Integer sleepMillis = 60*1000 // 1 minute 10 | Integer timeOut = 60*sleepMillis // 1 hour 11 | Integer timeWaited = 0 12 | String instanceId 13 | 14 | if (args.size() == 0) { 15 | instanceId = System.getenv("OMNI_DB_INSTANCE") 16 | if (instanceId == null) { 17 | println "OMNI_DB_INSTANCE env var must be defined or instanceId specified as command argument" 18 | } 19 | } else if (args.size() == 1) { 20 | instanceId = args[0] 21 | } else { 22 | println "Usage: waitForDBAvailable.groovy [instanceId]" 23 | System.exit(-1) 24 | } 25 | 26 | def credentials = new EnvironmentVariableCredentialsProvider().getCredentials() 27 | println "Creating RDS client..." 28 | def rds = new AmazonRDSClient(credentials) 29 | rds.region = Region.getRegion(Regions.US_WEST_2) 30 | 31 | println "Waiting for instance ${instanceId} to be 'available'..." 32 | String instanceStatus 33 | while (true) { 34 | instanceStatus = getStatus(rds, instanceId) 35 | println "Status is: ${instanceStatus}" 36 | if (instanceStatus == 'available') { 37 | break 38 | } else if (timeWaited > timeOut ) { 39 | println "Timeout" 40 | System.exit(-1) 41 | } 42 | sleep sleepMillis 43 | timeWaited += sleepMillis 44 | } 45 | 46 | String getStatus(def rds, String instanceId) { 47 | def req = new DescribeDBInstancesRequest().withDBInstanceIdentifier(instanceId) 48 | def instance = rds.describeDBInstances(req).getDBInstances()[0] 49 | def status = instance.getDBInstanceStatus() 50 | } 51 | -------------------------------------------------------------------------------- /omniwallet-synced/res/app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | kill_child_processes() { 4 | kill $SERVER_PID 5 | rm -f $LOCK_FILE 6 | } 7 | 8 | # Ctrl-C trap. Catches INT signal 9 | trap "kill_child_processes 1 $$; exit 0" INT 10 | echo "Starting app.sh: $(TZ='America/Chicago' date)" 11 | 12 | echo "Establishing environment variables..." 13 | APPDIR=`pwd` 14 | TOOLSDIR=$APPDIR 15 | DATADIR="/var/lib/mastercoin-tools" 16 | LOCK_FILE=$DATADIR/msc_cron.lock 17 | PARSE_LOG=$DATADIR/parsed.log 18 | VALIDATE_LOG=$DATADIR/validated.log 19 | ARCHIVE_LOG=$DATADIR/archived.log 20 | 21 | mkdir -p $DATADIR 22 | # Export directories for API scripts to use 23 | export TOOLSDIR 24 | export DATADIR 25 | 26 | if [ ! -d $DATADIR/tx ]; then 27 | cp -r $TOOLSDIR/www/tx $DATADIR/tx 28 | fi 29 | 30 | cd $DATADIR 31 | mkdir -p tmptx tx addr general offers wallets sessions mastercoin_verify/addresses mastercoin_verify/transactions www 32 | SERVER_PID=$! 33 | 34 | if [ "$1" = "-status" ]; then 35 | cat $DATADIR/www/revision.json | cut -d"," -f3 36 | cat $DATADIR/www/revision.json | cut -d"," -f4 37 | exit 38 | fi 39 | 40 | echo "Beginning main run loop..." 41 | while true 42 | do 43 | 44 | # check lock (not to run multiple times) 45 | if [ ! -f $LOCK_FILE ]; then 46 | 47 | #mkdir -p $DATADIR 48 | #cd $DATADIR 49 | #mkdir -p tmptx tx addr general offers wallets sessions mastercoin_verify/addresses mastercoin_verify/transactions www 50 | 51 | # lock 52 | touch $LOCK_FILE 53 | 54 | # parse until full success 55 | x=1 # assume failure 56 | echo -n > $PARSE_LOG 57 | 58 | while [ "$x" != "0" ]; 59 | do 60 | echo "Parsing last block $(cat www/revision.json | cut -b 102-109) at $(TZ='America/Chicago' date)" 61 | python $TOOLSDIR/msc_parse.py -r $TOOLSDIR 2>&1 >> $PARSE_LOG 62 | x=$? 63 | done 64 | 65 | echo "Running validation step..." 66 | python $TOOLSDIR/msc_validate.py 2>&1 > $VALIDATE_LOG 67 | 68 | # echo "Getting price calculation..." 69 | # mkdir -p $DATADIR/www/values $DATADIR/www/values/history 70 | # python $APPDIR/api/coin_values.py 71 | 72 | # update archive 73 | echo "Running archive tool..." 74 | python $TOOLSDIR/msc_archive.py -r $TOOLSDIR 2>&1 > $ARCHIVE_LOG 75 | 76 | mkdir -p $DATADIR/www/tx $DATADIR/www/addr $DATADIR/www/general $DATADIR/www/offers $DATADIR/www/mastercoin_verify/addresses $DATADIR/www/mastercoin_verify/transactions 77 | 78 | echo "Copying data back to /www/ folder..." 79 | find $DATADIR/tx/. -name "*.json" | xargs -I % cp -rp % $DATADIR/www/tx 80 | find $DATADIR/addr/. -name "*.json" | xargs -I % cp -rp % $DATADIR/www/addr 81 | find $DATADIR/general/. -name "*.json" | xargs -I % cp -rp % $DATADIR/www/general 82 | find $DATADIR/offers/. -name "*.json" | xargs -I % cp -rp % $DATADIR/www/offers 83 | find $DATADIR/mastercoin_verify/addresses/. | xargs -I % cp -rp % $DATADIR/www/mastercoin_verify/addresses 84 | find $DATADIR/mastercoin_verify/transactions/. | xargs -I % cp -rp % $DATADIR/www/mastercoin_verify/transactions 85 | 86 | # unlock 87 | rm -f $LOCK_FILE 88 | fi 89 | 90 | # Wait a minute, and do it all again. 91 | echo "Done, sleeping..." 92 | sleep 60 93 | done 94 | -------------------------------------------------------------------------------- /adoc/jenkins.adoc: -------------------------------------------------------------------------------- 1 | = Jenkins Continuous Integration Server 2 | :numbered: 3 | 4 | The Omni Foundation is running a Jenkins continuous integration server at http://ci.omni.foundation[ci.omni.foundation]. 5 | 6 | These are the current (as of Jan 20th, 2015) jobs with explanations. 7 | 8 | == Omni Core (Master Core) 9 | 10 | === Build Jobs 11 | 12 | [options="header",frame="all"] 13 | |=== 14 | | Job Name | Github Repo | Branch | Test Jobs Triggered | Notes 15 | 16 | | http://ci.omni.foundation/job/omnicore-stable/[omnicore-stable] 17 | | https://github.com/mastercoin-MSC/mastercore/[mastercoin-MSC/mastercore] 18 | | mscore-0.0.8 19 | | `msc-mainnet-consensus`, `msc-integ-regtest` 20 | a| Tip of Git branch for latest "stable" Omni Core 21 | 22 | * Builds `mastercored` 23 | * Runs included C++ Boost unit tests. 24 | 25 | | http://ci.omni.foundation/job/omnicore-stable/[omnicore-integration] 26 | | https://github.com/mastercoin-MSC/mastercore/[mastercoin-MSC/mastercore] 27 | | mscore-0.0.9 28 | | `msc-mainnet-consensus`, `msc-integ-regtest` 29 | a| Tip of development/integration/unstable Omni Core branch 30 | 31 | * Builds `mastercored` 32 | * Runs included C++ Boost unit tests. 33 | 34 | | http://ci.omni.foundation/job/OmniJ/[OmniJ] 35 | | https://github.com/OmniLayer/OmniJ[OmniLayer/OmniJ] 36 | | master 37 | | none (see notes) 38 | a| `OmniJ` repo contains OmniJ library, test support, and tests. This job: 39 | 40 | * Builds `OmniJ` jars 41 | * Builds http://ci.omni.foundation/job/OmniJ/javadoc/[OmniJ API documentation] 42 | * Does *not* trigger integration tests because those jobs are directly triggered by changes to the `OmniJ` repo. 43 | 44 | |=== 45 | 46 | === Integration Test Jobs 47 | 48 | [options="header",frame="all"] 49 | |=== 50 | | Job Name | Github Repo | Branch | Parameters | Notes 51 | 52 | | http://ci.omni.foundation/job/msc-integ-regtest[msc-integ-regtest] 53 | | https://github.com/OmniLayer/OmniJ[OmniLayer/OmniJ] 54 | | master 55 | a| 56 | 57 | * `JOBNAME_TO_TEST`: Job that built the `mastercored` under test (`omnicore-stable` or `omnicore-integration`) 58 | a| Runs integration tests of JSON-RPC commands against `mastercored` running in https://bitcoin.org/en/developer-examples#regtest-mode[RegTest Mode] 59 | 60 | * Job shell script: https://github.com/OmniLayer/OmniJ/blob/master/test-msc-integ-regtest.sh[test-msc-integ-regtest.sh] 61 | * Gradle task: `regTest` 62 | 63 | | http://ci.omni.foundation/job/msc-mainnet-consensus[msc-mainnet-consensus] 64 | | https://github.com/OmniLayer/OmniJ[OmniLayer/OmniJ] 65 | | master 66 | a| 67 | 68 | * `JOBNAME_TO_TEST`: Job that built the `mastercored` under test (`omnicore-stable` or `omnicore-integration`) 69 | a| Runs consensus tests using JSON-RPC commands against `mastercored` running on *Main Net*. 70 | 71 | * Job shell script: https://github.com/OmniLayer/OmniJ/blob/master/test-msc-consensus-mainnet.sh[test-msc-consensus-mainnet.sh] 72 | * Gradle task: `consensusTest` 73 | 74 | |=== 75 | 76 | == Bitcoin Core Build and Integration RegTest 77 | 78 | We are building and testing Bitcoin Core for the following reasons: 79 | 80 | . So we can compare test results between Omni Core and Bitcoin Core 81 | . To test our tests against Bitcoin Core 82 | . To allow us to prepare a subset of our tests for submitting upstream. 83 | 84 | === Build Job 85 | 86 | [options="header",frame="all"] 87 | |=== 88 | | Job Name | Github Repo | Branch | Test Jobs Triggered | Notes 89 | 90 | | http://ci.omni.foundation/job/bitcoin-core/[bitcoin-core] 91 | | https://github.com/bitcoin/bitcoin/[bitcoin/bitcoin] 92 | | 0.9.3 93 | | `btc-integ-regtest` 94 | a| 95 | 96 | * Builds latest shipping version of `bitcoind` 97 | * Runs included C++ Boost unit tests. 98 | 99 | |=== 100 | 101 | === Integration Test Job 102 | 103 | [options="header",frame="all"] 104 | |=== 105 | | Job Name | Github Repo | Branch | Parameters | Notes 106 | 107 | | http://ci.omni.foundation/job/btc-integ-regtest[btc-integ-regtest] 108 | | https://github.com/OmniLayer/OmniJ[OmniLayer/OmniJ] 109 | | master 110 | | 111 | a| 112 | 113 | . Job shell script: https://github.com/OmniLayer/OmniJ/blob/master/test-btc-integ-regtest.sh[test-btc-integ-regtest.sh] 114 | . Gradle task: `regTestBTC` 115 | 116 | |=== 117 | 118 | == OmniEngine Database Schema Test Jobs 119 | 120 | Documentation TBD. 121 | 122 | 123 | -------------------------------------------------------------------------------- /omniwallet-synced/install-omni.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Tested on Ubuntu 14.04 LTS 3 | #set -e 4 | set -e -x 5 | REPOURL=$1 6 | BRANCH=$2 7 | 8 | #Set some Variables 9 | NAME=`logname` 10 | PIPFILELOC="/home/$NAME/omniwallet" 11 | 12 | if [ ! -f ~/.ssh/id_rsa.pub ]; then 13 | SSHGEN= 14 | while [ -z "$SSHGEN" ]; do 15 | echo "Public ssh key not found in ~/.ssh/id_rsa" 16 | echo "Do you wish to generate one now?[y/n]" 17 | SSHGEN='n' 18 | done 19 | case $SSHGEN in 20 | 21 | y* | Y* ) 22 | echo "Generating ~/.ssh/id_rsa:" 23 | echo n | sudo -u $NAME ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" 24 | ;; 25 | *) 26 | echo "Slipping new ssh key generation" 27 | ;; 28 | esac 29 | fi 30 | 31 | echo "#############################" 32 | echo "Adding your SSH key to Github" 33 | echo "Before Continuing please follow Steps 3 and 4 of the Github SSH key guide" 34 | echo "https://help.github.com/articles/generating-ssh-keys" 35 | echo "" 36 | echo "Your SSH key from ~/.ssh/id_rsa.pub is:" 37 | echo "----------------------------------------------------------------------------------" 38 | #cat ~/.ssh/id_rsa.pub 39 | echo "----------------------------------------------------------------------------------" 40 | echo "" 41 | echo "#############################" 42 | 43 | SSH="sudo -s -u $NAME ssh -o StrictHostKeyChecking=no -T -q git@github.com" 44 | 45 | VALID=0 # do not run 46 | while [ $VALID -ne 0 ]; do 47 | echo "When You have updated Github please enter exactly:" 48 | echo " SSH Key Updated" 49 | read SSHREP 50 | if [[ $SSHREP == "SSH Key Updated" ]]; then 51 | sshout=`${SSH} > /dev/null 2>&1 || echo $?` 52 | if [[ $sshout -eq 1 ]]; then 53 | echo "SSH Key Matched: Proceeding" 54 | VALID=0 55 | else 56 | echo "Something didn't work, check your key and try again" 57 | SSHREP="Nope" 58 | fi 59 | fi 60 | done 61 | 62 | # do this before starting 63 | sudo apt-get autoremove 64 | # Make sure we're getting the newest packages. 65 | sudo apt-get update 66 | #Make sure we have python and build tools 67 | sudo apt-get -y install python-software-properties python 68 | sudo add-apt-repository -y ppa:chris-lea/node.js 69 | sudo add-apt-repository -y ppa:nginx/stable 70 | sudo apt-get update 71 | 72 | # If this is a local image, you may need sshd set up. 73 | sudo apt-get -y install openssh-server openssh-client 74 | 75 | # Install some system stuff 76 | sudo apt-get -y install daemontools 77 | 78 | # Get your tools together 79 | sudo apt-get -y install vim git curl libssl-dev make 80 | 81 | # Stuff so you can compile 82 | sudo apt-get -y install gcc g++ lib32z1-dev pkg-config ant 83 | sudo apt-get -y install ruby 84 | echo "installing sass..." 85 | sudo gem install sass 86 | echo "done." 87 | sudo apt-get -y install python-dev python-setuptools 88 | 89 | #Special node.js installation from chris-lea repository 90 | sudo apt-get -y install nodejs 91 | 92 | # Get forever, install globally 93 | sudo npm install -g forever 94 | 95 | # Make it so that grunt can be used 96 | sudo npm install -g grunt-cli 97 | 98 | # Other node-based compilation tools 99 | sudo npm install -g less 100 | sudo npm install -g jshint 101 | 102 | #Get/clone Omniwallet - might be relevant 103 | echo "cloning omniwallet into $HOME" 104 | cd $HOME 105 | git clone --no-checkout $REPOURL omniwallet 106 | cd omniwallet 107 | git checkout $BRANCH 108 | cd $HOME 109 | 110 | # May need to clean up some strange permissions from the npm install. 111 | sudo chown -R $NAME:$NAME ~/.npm 112 | #sudo chown -R $NAME:$NAME ~/tmp 113 | 114 | #install packages: 115 | sudo apt-get -y install python-simplejson python-git python-pip libffi-dev 116 | sudo apt-get -y install build-essential autoconf libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev libpq-dev 117 | 118 | #sx install is run earlier 119 | 120 | #Pip requirements 121 | #sudo pip install -r $SRC/pip.packages 122 | sudo pip install -r $PIPFILELOC/requirements.txt 123 | 124 | #fix for incompleteread bug 125 | sudo rm -rf /usr/local/lib/python2.7/dist-packages/requests 126 | sudo pip install requests 127 | 128 | #Get and setup nginx 129 | sudo apt-get -y install uwsgi uwsgi-plugin-python 130 | sudo apt-get -y install nginx 131 | 132 | sed -i "s/myUser/$NAME/g" ~/omniwallet/etc/nginx/sites-available/default 133 | sed -i "s/\/var\/lib\/omniwallet\/www\/values.json/\/home\/$NAME\/omniwallet\/var\/lib\/omniwallet\/www\/values.json/g" ~/omniwallet/etc/nginx/sites-available/default 134 | 135 | #Update nginx conf with omniwallet specifics 136 | sudo cp ~/omniwallet/etc/nginx/sites-available/default /etc/nginx/sites-available 137 | 138 | sudo npm install -g uglify-js 139 | 140 | #Start the omniwallet dependency setup 141 | sudo chown -R $NAME:$NAME ~/omniwallet 142 | cd ~/omniwallet 143 | sudo -u $NAME npm install 144 | sudo -u $NAME sudo npm install bower -g 145 | sudo -u $NAME grunt 146 | 147 | #Create omniwallet data directory 148 | sudo mkdir -p /var/lib/omniwallet 149 | sudo chown -R $NAME:$NAME /var/lib/omniwallet 150 | 151 | #start the web interface 152 | sudo nginx -s stop 153 | sudo nginx 154 | 155 | set +x 156 | echo "" 157 | echo "Installation complete" 158 | echo "Omniwallet should have been downloaded/installed in "$PWD 159 | echo "Omniwallet will be accessible at port 80 after running ./app.sh in ~/omniwallet/" 160 | echo "(If you're using Vagrant/Virtualbox port 80 in this VM is typically mapped to localhost:1666)" 161 | echo "" 162 | echo "" 163 | echo "The webinterface is handled by nginx" 164 | echo "'sudo service nginx [stop/start/restart/status]'" 165 | echo "" 166 | echo "There is a wrapper app.sh which runs Omniwallet." 167 | echo "" 168 | echo "" 169 | echo "----------------Run Commands------------------" 170 | echo "Start a new screen session with: screen -S omni" 171 | echo "cd "$PWD 172 | echo "Set an environment variable containing a secret passphrase - this is used to generate salts for indivdual" 173 | echo "user IDs, and it needs to be both secret AND not change." 174 | echo "" 175 | echo " export OMNIWALLET_SECRET=\"DontTellAnyoneThis\"" 176 | echo "" 177 | echo "launch the wrapper: ./app.sh" 178 | echo "Note: Do NOT launch it with sudo" 179 | echo "You can disconnect from the screen session with ' d'" 180 | echo "You can reconnect to the screen session with 'screen -r omni'" 181 | echo "----------------------------------" 182 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | # Specify minimum Vagrant version 8 | Vagrant.require_version ">= 1.6.2" 9 | 10 | # Load external configuration from LocalVagrantConfig.rb (if present) 11 | # else load it from DefaultVagrantConfig.rb 12 | LOCAL_CONFIG_RB="#{File.dirname(__FILE__)}/LocalVagrantConfig.rb"; 13 | DEFAULT_CONFIG_RB="#{File.dirname(__FILE__)}/DefaultVagrantConfig.rb"; 14 | if File.exist?(LOCAL_CONFIG_RB) 15 | # puts "Loading local config from #{LOCAL_CONFIG_RB}" 16 | require LOCAL_CONFIG_RB 17 | else 18 | # puts "Loading default config from #{DEFAULT_CONFIG_RB}" 19 | require DEFAULT_CONFIG_RB 20 | end 21 | 22 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 23 | config.vm.boot_timeout = 720 24 | # Every Vagrant virtual environment requires a box to build off of. 25 | # Version 0.2.0 is Ubuntu 14.04 LTS built from "ubuntu/trusty64" 26 | config.vm.box = "msgilligan/mastercoin-ubuntu-base" 27 | config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true 28 | config.vm.synced_folder "synced", "/vagrant", id: "vagrant-synced", disabled: false 29 | 30 | config.vm.provider "virtualbox" do |v| 31 | v.memory = 3840 # 3.75 GB, same as Amazon m3.medium 32 | v.cpus = 4 33 | #v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] #limit the use of cpu to 50% 34 | end 35 | 36 | config.vm.provider :aws do |aws, override| 37 | aws.access_key_id = ENV['AWS_ACCESS_KEY'] || "" 38 | aws.secret_access_key = ENV['AWS_SECRET_KEY'] || "" 39 | aws.keypair_name = ENV['AWS_KEYPAIR_NAME'] || "" 40 | 41 | aws.region = AWS_DEFAULT_REGION 42 | aws.instance_type = "t2.small" 43 | aws.security_groups = [ 'web' ] 44 | 45 | aws.ami = "ami-39501209" # uswest-2, amd64, type="hvm:ebs", Release: 20140927 46 | 47 | aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 60, 'Ebs.DeleteOnTermination' => false }] 48 | 49 | override.vm.box = "omni-aws" 50 | override.ssh.username = "ubuntu" 51 | override.ssh.private_key_path = ENV['AWS_SSH_KEY_PATH'] || "" 52 | end 53 | 54 | # 55 | # base 56 | # 57 | # Configuration for a base Ubuntu VM for Mastercoin 58 | # 59 | # Updated Ubuntu, make, git, libboost, etc 60 | # See install-mastercoin-base-root.sh for details 61 | # 62 | # This VM is published on https://vagrantcloud.com as 63 | # 'msgilligan/mastercoin-ubuntu-base' and used as the 64 | # base box by all other VMs in this Vagrantfile. 65 | # 66 | config.vm.define "base", autostart: false do |base| 67 | base.vm.box = "ubuntu/trusty64" 68 | base.vm.provision "shell" do |s| 69 | s.path = "install-mastercoin-base-root.sh" 70 | end 71 | end 72 | 73 | # 74 | # empty 75 | # 76 | # Configuration for an empty install based on 'base' 77 | # 78 | config.vm.define "empty", autostart: false do |empty| 79 | end 80 | 81 | 82 | # 83 | # omniwallet 84 | # 85 | # Configuration for Ubuntu VM with Omniwallet 86 | # 87 | # Production is m1.small (do we need that instance storage or should we use a t2 or m3 instance?) 88 | # Currently testing with t2.small 89 | # 90 | config.vm.define "omniwallet" do |omni| 91 | 92 | omni.vm.network :forwarded_port, host_ip: "127.0.0.1", guest: 80, host: 1666 93 | omni.vm.synced_folder "omniwallet-synced", "/vagrant", id: "vagrant-synced", disabled: false 94 | 95 | omni.vm.provision "shell" do |s| 96 | s.privileged = false 97 | s.path = "install-omniwallet-user.sh" 98 | s.args = [OMNIWALLET_GIT_REPO, # Git Repo to clone/checkout from 99 | OMNIWALLET_GIT_BRANCH, # Branch to checkout 100 | BTCRPC_CONNECT, # Bitcoin RPC Host 101 | BTCRPC_USER, # Bitcoin RPC username 102 | BTCRPC_PASSWORD, # Bitcoin RPC password 103 | BTCRPC_SSL, # Use SSL for RPC 104 | PGHOST, # Postgres host 105 | OMNIDB_WWW_USER, # Postgres username 106 | OMNIDB_WWW_PASSWORD, # Postgres password 107 | PGPORT] # Postgres port 108 | end 109 | 110 | omni.vm.provider "virtualbox" do |v| 111 | v.memory = 1024 112 | v.cpus = 2 113 | end 114 | 115 | omni.vm.provider "aws" do |aws| 116 | aws.tags = { 117 | 'Name' => 'omniwallet', 118 | 'Type' => 'vagrant-omniwallet' 119 | } 120 | end 121 | 122 | end 123 | 124 | 125 | # 126 | # omniengine 127 | # 128 | # Configuration for Ubuntu VM with OmniEngine 129 | # 130 | # Production is t2.micro 131 | # 132 | config.vm.define "omniengine" do |omni| 133 | 134 | omni.vm.synced_folder "omniengine-synced", "/vagrant", id: "vagrant-synced", disabled: false 135 | 136 | 137 | omni.vm.provision "shell" do |s| 138 | s.privileged = false 139 | s.path = "install-omniengine-user.sh" 140 | s.args = [OMNIENGINE_GIT_REPO, # Repo to clone 141 | OMNIENGINE_GIT_BRANCH, # Branch to checkout 142 | BTCRPC_CONNECT, # Bitcoin RPC Host 143 | BTCRPC_USER, # Bitcoin RPC username 144 | BTCRPC_PASSWORD, # Bitcoin RPC password 145 | BTCRPC_SSL, # Use SSL for RPC 146 | PGHOST, # Postgres host 147 | OMNIDB_ENGINE_USER, # Postgres username 148 | OMNIDB_ENGINE_PASSWORD, # Postgres password 149 | PGPORT] # Postgres port 150 | end 151 | 152 | omni.vm.provider "virtualbox" do |v| 153 | v.memory = 1024 154 | v.cpus = 2 155 | end 156 | 157 | omni.vm.provider "aws" do |aws| 158 | aws.instance_type = "t2.micro" 159 | aws.tags = { 160 | 'Name' => 'omniengine', 161 | 'Type' => 'vagrant-omniengine' 162 | } 163 | end 164 | 165 | end 166 | 167 | 168 | # 169 | # mastercore 170 | # 171 | # Configuration for Master Core deployment 172 | # 173 | # Master Core is currently built from source code. 174 | # 175 | # Omni Production is m3.medium 176 | # Currently testing with t2.small 177 | # 178 | config.vm.define "mastercore", autostart: false do |mastercore| 179 | 180 | mastercore.vm.synced_folder "mastercore-synced", "/vagrant", id: "vagrant-synced", disabled: false 181 | 182 | mastercore.vm.network :forwarded_port, host_ip: "127.0.0.1", guest: 8332, host: 38332 183 | 184 | mastercore.vm.provision "shell" do |s| 185 | s.path = "install-mastercoin-base-root.sh" 186 | end 187 | 188 | mastercore.vm.provision "shell" do |s| 189 | s.privileged = false 190 | s.path = "clone-build-install-bitcoind.sh" 191 | s.args = [MASTERCORE_GIT_REPO, # Git Repo to clone/checkout from 192 | MASTERCORE_GIT_BRANCH, # Branch to check out 193 | "mastercore", # Directory to clone into 194 | BTCRPC_CONNECT, # Bitcoin RPC Host 195 | BTCRPC_USER, # Bitcoin RPC username 196 | BTCRPC_PASSWORD, # Bitcoin RPC password 197 | BTCRPC_SSL, # Use SSL for RPC 198 | "*"] # BTCRPC_ALLOWIP -- IP addresses to allow 199 | end 200 | 201 | mastercore.vm.provider "virtualbox" do |v| 202 | v.memory = 2048 203 | v.cpus = 8 204 | end 205 | 206 | mastercore.vm.provider "aws" do |aws| 207 | aws.tags = { 208 | 'Name' => 'mastercore', 209 | 'Type' => 'vagrant-mastercore' 210 | } 211 | end 212 | 213 | end 214 | 215 | end 216 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Omniwallet, OmniEngine, and Master Core Devops 2 | 3 | **This repository is unmaintained and years out of date. It needs a major overhaul/update before it is useful again.** 4 | 5 | We are looking for a new maintainer, if you think you can help, please see https://github.com/OmniLayer/omni-devops/issues/10. 6 | 7 | Deployment and management scripts for the new Master Core-based Omniwallet. 8 | 9 | Omniwallet consists of 4 main components/servers. The *Vagrantfile* in this repository contains VM configurations for 3 of these components. We are currently focused on using [Amazon RDS](http://aws.amazon.com/rds/postgresql/) for the PostgreSQL server component, but PostgreSQL could be run from a Vagrant VM or any PostgreSQL server host. 10 | 11 | 1. Master Core RPC Server: `mastercore` VM 12 | 1. PostgreSQL Database Server: PostgreSQL or Amazon RDS 13 | 1. OmniEngine Server: `omniengine` VM 14 | 1. Omniwallet Server: `omniwallet` VM (in progress, be prepared to help debug) 15 | 16 | Although it should be possible to deploy all four servers in a single virtual (or physical) machine, it is recommended to use four seprate VMs and these scripts are currently designed to build and deploy 4 separate VMs. 17 | 18 | ## Prerequisites 19 | 20 | * Virtual Box 4.3.10 or later 21 | * Vagrant 1.6.2 or later 22 | 23 | Vagrant is available for Mac OS X, Windows, and Linux. In addition to VirtualBox, Vagrant may be used to provision VMWare, AWS and other virtual environments. 24 | 25 | ## Recommended/Optional tools 26 | 27 | * [Bash](http://www.gnu.org/software/bash/) command-line shell 28 | * [PostgreSQL](http://www.postgresql.org/download/) command line client tools 29 | * [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 30 | * [Groovy language](http://beta.groovy-lang.org/download.html) 31 | * Amazon [EC2 CLI Tools](http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ec2-cli-get-set-up.html) 32 | * Amazon [RDS Command Line Tools](http://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/StartCLI.html) 33 | 34 | ### Base Box 35 | 36 | The [Vagrantfile](Vagrantfile) is currently using (*trusting*) the [ubuntu/trusty64](https://vagrantcloud.com/ubuntu/trusty64) base box created by Ubuntu and the Mastercoin base box [msgilligan/mastercoin-ubuntu-base](https://vagrantcloud.com/msgilligan/mastercoin-ubuntu-base). 37 | 38 | You should consider them untrusted binaries. Only use them with TEST-MSC and small amounts of Bitcoin. 39 | 40 | ## Installing Prerequisites 41 | 42 | 1. [Install VirtualBox](https://www.virtualbox.org/manual/ch02.html) 43 | 1. [Install Vagrant](http://docs.vagrantup.com/v2/installation/) 44 | 1. Clone this repository and check out the 'master' branch 45 | 46 | $ git clone git@github.com:mastercoin-MSC/omni-devops.git 47 | $ cd omni-devops 48 | 49 | ## Installing support for AWS 50 | 51 | The instructions for setting up the various servers show the `--provider=aws` option enclosed in square brackets `[` `]` which indicates that it is an optional option. If used, the `--provider=aws` option requires that Vagrant have support for AWS installed and a AWS base box named "omni-aws" created. (If the option is not specified, Vagrant will use VirtualBox on your local system, in which case you can skip this section.) 52 | 53 | 1. Install the Vagrant AWS plugins 54 | 55 | $ vagrant plugin install vagrant-aws 56 | $ vagrant plugin install vagrant-awsinfo 57 | 58 | 1. Create the Omni AWS Vagrant Base Box 59 | 60 | $ cd omni-devops 61 | $ vagrant box add omni-aws tools/omni-aws.box 62 | 63 | ## Master Core RPC Server Setup 64 | 65 | VM name `mastercore` 66 | 67 | 1. Copy `DefaultVagrantConfig.rb` to `LocalVagrantConfig.rb` and make sure `LocalVagrantConfig.rb` contains the correct values for Master Core RPC setup. For the `mastercore` VM you'll need to set the AWS variables (starting with `AWS_`, except `AWS_CREDENTIAL_FILE`), the `OMNIENGINE_GIT_REPO` and `OMNIENGINE_GIT_BRANCH` setting to specify where to fetch the source to build from, and the `BTCRPC_` variables (except `BTCRPC_CONNECT` which isn't needed to create the `mastercore` VM, but to access it). 68 | 69 | 1. Make sure `mastercore-synced/openssl.cnf` has the values you want for your self-signed SSL certificate. 70 | 71 | 1. Create and boot a VM with Vagrant and install Master Core 72 | 73 | $ vagrant up mastercore [--provider=aws] 74 | 75 | The Master Core daemon is now running as an Ubuntu service and will be automatically restarted upon system reboots as well as if the daemon crashes. 76 | 77 | 1. If you have not done so already set the `BTCRPC_CONNECT` variable in `LocalVagrantConfig.rb` to the hostname or IP address of the `mastercore` VM that you just created. 78 | 79 | ## PostgreSQL Database Server Setup 80 | 81 | Although [PostgreSQL](http://www.postgresql.org) may be run in a general purpose VM, development at the Mastercoin Foundation has been focused upon using the [RDS database service](http://aws.amazon.com/rds/postgresql/) provided by Amazon. 82 | 83 | To create your own PostgreSQL instance using Amazon RDS, follow these steps: 84 | 85 | 1. Make sure you have the AWS EC2 Tools and AWS RDS Tools installed corectly. 86 | 87 | 1. Make sure you have the Groovy language installed correctly. 88 | 89 | 1. Copy the environment setup template file. 90 | 91 | $ cp setup-omni-template.sh setup-omni-private.sh 92 | $ chmod 700 setup-omni-private.sh 93 | 94 | 1. Edit `setup-omni-private.sh` and make sure to set (at least) the following variables: `AWS_ACCESS_KEY`, `AWS_SECRET_KEY`, `AWS_CREDENTIAL_FILE`, `PGUSER`, `PGPASSWORD`, `OMNI_DB_INSTANCE`, `OMNI_DB_SEC_GID` 95 | 96 | 1. Run the following commands: 97 | 98 | $ source setup-omni-private.sh 99 | $ cd rds 100 | $ ./create-omnidb-instance.sh 101 | $ ./waitForDBAvailable.groovy 102 | 103 | 1. Use the `./list-rds-instances.sh` command to find the hostname of the RDS instance 104 | 105 | ## OmniEngine Server Setup 106 | 107 | VM name `omniengine` 108 | 109 | 1. Copy `DefaultVagrantConfig.rb` to `LocalVagrantConfig.rb` and make sure `LocalVagrantConfig.rb` contains the correct host, username, and password values for the PostgreSQL and Master Core RPC servers. 110 | 111 | 1. Create and boot a VM with Vagrant and install and run OmniEngine 112 | 113 | $ vagrant up omniengine [--provider=aws] 114 | 115 | ## Omniwallet Server Setup 116 | 117 | VM name `omniwallet` 118 | 119 | NOTE: THE OMNIWALLET VM INSTALL IS PRE-ALPHA. It is now working, BUT HAS HAD MINIMAL TESTING. Please give it a try. 120 | 121 | FEEDBACK AND/OR PULL REQUESTS WELCOME. 122 | 123 | 1. Copy `DefaultVagrantConfig.rb` to `LocalVagrantConfig.rb` and make sure `LocalVagrantConfig.rb` contins the correct host, username, and password values for the PostgreSQL and Master Core RPC servers. 124 | 125 | 1. Create and boot a VM with Vagrant and install and Omniwallet 126 | 127 | $ vagrant up omniwallet [--provider=aws] 128 | 129 | 1. Connect to the `omniwallet` VM 130 | 131 | $ vagrant ssh omniwallet 132 | 133 | 1. Make sure `nginx` is running: 134 | 135 | $ sudo service nginx status 136 | 137 | 1. Set an environment variable containing a secret passphrase. It is used to generate salts for individual user IDs, and it needs to be both secret AND not change. 138 | 139 | export OMNIWALLET_SECRET="DontTellAnyoneThis" 140 | 141 | 1. Configure an email server for sending account information. 142 | 143 | 1. Launch the wrapper (do *NOT* use `sudo`) 144 | 145 | $ cd omniwallet 146 | $ mkdir -p logs 147 | $ ./app.sh &> logs/appsh.log & 148 | 149 | 1. Use your browser to go to the correct port on the newly installed VM. You should see Omniwallet running there. 150 | 151 | 152 | ## Troubleshooting Tips 153 | 154 | ### Vagrant/VirtualBox 155 | 156 | 1. Make sure that Vagrant (and VirtualBox) are installed correctly. You can use the `empty` VM provided in the *Vagrantfile* to quickly test that Vagrant is working correctly. The empty VM does not contain any Master Core or Omni services but offers a quick test that Vagrant and the supporting "provider" are working and configured correctly. 157 | 158 | $ vagrant up empty [--provider=aws] 159 | 160 | 1. If you're running Vagrant from Microsoft Windows make sure that the text files you checked out with Git have UNIX line seperators not MS-DOS/Winodws CRLF line seperators. If you get an error message which complains about `\r` characters, check your Git configuration. The [`.gitattributes`](https://github.com/mastercoin-MSC/omni-devops/blob/master/.gitattributes) file in this repository is now configured to ensure that even on Windows, text files have lines separated by LF, not CRLF. 161 | 162 | 1. If you're using Virtualbox on Windows and your Windows host is becoming unresponsive, you can try uncommenting the following line in `Vagrantfile`: 163 | 164 | v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] #limit the use of cpu to 50% 165 | 166 | 1. You can also reduce the number of CPUs used for a particular Virtualbox VM which may also help to reduce load on your host system. The configuration lines in `Vagrantfile` that you are interested in look like this: 167 | 168 | v.cpus = 2 169 | 170 | 1. If you're on Windows 8.1, don't use the `vagrant suspend` command because of this [VirtualBox bug](https://www.virtualbox.org/ticket/13583). (There's also a [Vagrant Issue](https://github.com/mitchellh/vagrant/issues/4276) with more specific information and some workarounds.) 171 | 172 | ### Master Core VM 173 | 174 | 1. Make sure you didn't skip the step to assign an RPC username and password. 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /omniwallet-synced/res/install-sx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Script to install libbitcoin, libwallet, obelisk and sx tools. 4 | # 5 | # Install dependencies and compiles the source code from git for Debian 7 / Ubuntu 13.10 or Fedora GNU/Linux distributions. 6 | # 7 | # Requires sudo. 8 | # 9 | # To execute this script, run: 10 | # 11 | # 12 | # To read help instructions run: 13 | # 14 | # 15 | # 16 | set -e 17 | echo 18 | echo " [+] Welcome to S(pesmilo)X(changer)." 19 | echo 20 | if [ "$#" = "1" ]; then 21 | if [[ "$1" = /* ]]; then 22 | #Absolute path 23 | INSTALL_PREFIX=$1 24 | elif [ "$1" = "--help" ]; then 25 | echo " [+] Install script help:" 26 | echo " --> To execute this script type:" 27 | echo " " 28 | echo " --> To execute this script and install at a specific path type:" 29 | echo " " 30 | echo " This script will install libbitcoin, libwallet, obelisk and sx tools." 31 | echo " The standard path for the installation is /usr/local/" 32 | echo " The stardard path for the conf files is /etc." 33 | echo 34 | exit 35 | else 36 | #Relative path 37 | RELATIVE=`pwd` 38 | INSTALL_PREFIX=$RELATIVE/$1 39 | fi 40 | CONF_DIR=$INSTALL_PREFIX/etc 41 | RUN_LDCONFIG= 42 | ROOT_INSTALL=0 43 | elif [ `id -u` = "0" ]; then 44 | INSTALL_PREFIX=/usr/local 45 | CONF_DIR=/etc 46 | RUN_LDCONFIG=ldconfig 47 | ROOT_INSTALL=1 48 | else 49 | echo 50 | echo "[+] ERROR: This script must be run as root." 1>&2 51 | echo 52 | echo "" 53 | echo 54 | exit 55 | fi 56 | SRC_DIR=$INSTALL_PREFIX/src 57 | PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig 58 | mkdir -p $SRC_DIR 59 | mkdir -p $PKG_CONFIG_PATH 60 | #Set the obelsik version to install 61 | #From March 13 2014LIBW_VER=21447cc 62 | LIBW_VER=9be05b6 63 | #From March 13 2014 LIBB_VER=335489f 64 | LIBB_VER=ebadde8 65 | #From March 6 2014 OBE_VER=58f326d 66 | OBE_VER=4962e2c 67 | #From March 12 2014 SX_VER=a97f7be 68 | SX_VER=d9b566e 69 | # 70 | install_dependencies(){ 71 | flavour_id=`cat /etc/*-release | egrep -i "^ID=" | cut -f 2 -d "="` 72 | echo " Flavour: $flavour_id." 73 | echo 74 | if [ "$flavour_id" = "debian" ]; then 75 | if [ "$ROOT_INSTALL" = 1 ]; then 76 | # Debian dependencies 77 | D_DEPENDENCIES="git build-essential autoconf apt-utils libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev" 78 | sleep 0.5 79 | apt-get -y install $D_DEPENDENCIES 80 | fi 81 | elif [ "$flavour_id" = "ubuntu" ]; then 82 | if [ "$ROOT_INSTALL" = 1 ]; then 83 | # Ubuntu dependencies (some people have libboost1.53-dev installed, determine which is installed rather than error out. Defaults onto 1.49) 84 | for BOOST_VER in 1.49 1.53 1.54 1.55; do 85 | dpkg -s "libboost$BOOST_VER-dev" >/dev/null 2>&1 && U_BOOST=$BOOST_VER 86 | done 87 | [[ $U_BOOST && ${U_BOOST-x} ]] && echo "Found libboost $U_BOOST" || export U_BOOST=1.49 ; echo "Defaulting to libboost $U_BOOST" 88 | 89 | U_DEPENDENCIES="git build-essential autoconf apt-utils libtool pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++8-dev libncurses5-dev libboost$U_BOOST-all-dev" 90 | sleep 0.5 91 | apt-get -y install $U_DEPENDENCIES 92 | fi 93 | elif [ "$flavour_id" = "fedora" ]; then 94 | if [ "$ROOT_INSTALL" = 1 ]; then 95 | # Fedora dependencies 96 | F_DEPENDENCIES="gcc-c++ git autoconf libtool boost-devel pkgconfig libcurl-devel openssl-devel leveldb-devel zeromq zeromq3 zeromq-devel libconfig libconfig-devel ncurses-devel" 97 | sleep 0.5 98 | yum -y install $F_DEPENDENCIES 99 | fi 100 | elif [ "$flavour_id" = "arch" ]; then 101 | if [ "$ROOT_INSTALL" = 1 ]; then 102 | # Arch dependencies 103 | A_DEPENDENCIES="gcc git autoconf libtool boost pkg-config curl openssl leveldb zeromq libconfig ncurses" 104 | sleep 0.5 105 | pacman -S --asdeps --needed --noconfirm $A_DEPENDENCIES 106 | fi 107 | else 108 | echo 109 | echo " [+] ERROR: GNU/Linux flavour not supported: $flavour_id" 1>&2 110 | echo 111 | echo " Please, review the script." 112 | echo 113 | exit 114 | fi 115 | } 116 | 117 | install_libbitcoin(){ 118 | cd $SRC_DIR 119 | if [ -d "libbitcoin-git" ]; then 120 | echo 121 | echo " --> Updating Libbitcoin..." 122 | echo 123 | cd libbitcoin-git 124 | git checkout master 125 | git remote set-url origin https://github.com/spesmilo/libbitcoin.git 126 | git pull --rebase 127 | else 128 | echo 129 | echo " --> Downloading Libbitcoin from git..." 130 | echo 131 | git clone https://github.com/spesmilo/libbitcoin.git libbitcoin-git 132 | fi 133 | cd $SRC_DIR/libbitcoin-git 134 | git checkout $LIBB_VER 135 | echo 136 | echo " --> Beggining build process now...." 137 | echo 138 | autoreconf -i 139 | ./configure --enable-leveldb --prefix $INSTALL_PREFIX 140 | make 141 | make install 142 | $RUN_LDCONFIG 143 | echo 144 | echo " o/ Libbitcoin now installed." 145 | echo 146 | } 147 | 148 | install_libwallet(){ 149 | cd $SRC_DIR 150 | if [ -d "libwallet-git" ]; then 151 | echo 152 | echo " --> Updating Libwallet..." 153 | echo 154 | cd libwallet-git 155 | git checkout master 156 | git remote set-url origin https://github.com/spesmilo/libwallet.git 157 | git pull --rebase 158 | else 159 | echo 160 | echo " --> Downloading Libwallet from git..." 161 | echo 162 | git clone https://github.com/spesmilo/libwallet.git libwallet-git 163 | fi 164 | cd $SRC_DIR/libwallet-git 165 | git checkout $LIBW_VER 166 | echo 167 | echo " --> Beggining build process now...." 168 | echo 169 | autoreconf -i 170 | ./configure --prefix $INSTALL_PREFIX 171 | make 172 | make install 173 | $RUN_LDCONFIG 174 | echo 175 | echo " o/ Libwallet now installed." 176 | echo 177 | } 178 | 179 | install_obelisk(){ 180 | cd $SRC_DIR 181 | if [ -d "obelisk-git" ]; then 182 | echo 183 | echo " --> Updating Obelisk..." 184 | echo 185 | cd obelisk-git 186 | git checkout master 187 | git remote set-url origin https://github.com/spesmilo/obelisk.git 188 | git pull --rebase 189 | else 190 | echo 191 | echo " --> Downloading obelisk..." 192 | echo 193 | git clone https://github.com/spesmilo/obelisk.git obelisk-git 194 | fi 195 | cd $SRC_DIR/obelisk-git 196 | git checkout $OBE_VER 197 | echo 198 | echo " --> Beggining build process now..." 199 | echo 200 | autoreconf -i 201 | ./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX 202 | make 203 | make install 204 | $RUN_LDCONFIG 205 | echo 206 | echo " o/ Obelisk now installed." 207 | echo 208 | } 209 | 210 | install_sx(){ 211 | BIN_DIR=$INSTALL_PREFIX/bin 212 | rm -rf $BIN_DIR/sx-* 213 | cd $SRC_DIR 214 | if [ -d "sx-git" ]; then 215 | echo 216 | echo " --> Updating SX..." 217 | echo 218 | cd sx-git 219 | git checkout master 220 | git remote set-url origin https://github.com/spesmilo/sx.git 221 | git pull --rebase 222 | else 223 | echo 224 | echo " --> Downloading SX from git..." 225 | echo 226 | git clone https://github.com/spesmilo/sx.git sx-git 227 | fi 228 | cd $SRC_DIR/sx-git 229 | git checkout $SX_VER 230 | echo 231 | echo " --> Beggining build process now...." 232 | echo 233 | autoreconf -i 234 | ./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX 235 | make 236 | make install 237 | $RUN_LDCONFIG 238 | echo 239 | echo " o/ SX tools now installed." 240 | echo 241 | } 242 | 243 | show_finish_install_info(){ 244 | echo " --> Installation finished!" 245 | if [ "$ROOT_INSTALL" = "1" ]; then 246 | echo 247 | echo " Config Files are in: $CONF_DIR" 248 | echo " obelisk configuration files: $CONF_DIR/obelisk/*.cfg" 249 | echo " sx configuration file: ~/.sx.cfg (see $INSTALL_PREFIX/share/sx/sx.cfg for an example config file)" 250 | echo 251 | echo " Documentation available /usr/local/doc:" 252 | echo " libbitcoin doc: $INSTALL_PREFIX/share/doc/libbitcoin/" 253 | echo " obelisk doc: $INSTALL_PREFIX/share/doc/obelisk/" 254 | echo " sx doc: $INSTALL_PREFIX/share/doc/sx/" 255 | echo 256 | elif [ "$ROOT_INSTALL" = "0" ]; then 257 | echo 258 | echo " Add these lines to your ~/.bashrc" 259 | echo " export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib" 260 | echo " export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig" 261 | echo " export PATH=\$PATH:$INSTALL_PREFIX/bin" 262 | fi 263 | echo 264 | echo " To setup a obelisk node, you will need obworker and obbalancer daemons running." 265 | echo " Run to create, configure and start the daemons." 266 | echo 267 | } 268 | 269 | install_dependencies 270 | install_libbitcoin 271 | install_libwallet 272 | install_obelisk 273 | install_sx 274 | show_finish_install_info 275 | --------------------------------------------------------------------------------