#!/bin/bash # Install the Reactor server in an Ubuntu or Centos6 environment. # Can be run interactively: # sudo bash setup-server.sh # Or passed to an instance via cloud-init: # nova boot ... --user-data setup-server.sh ... set -x set -e KEYFILE=$(mktemp) cleanup() { rm -f $KEYFILE } trap cleanup EXIT # This is the GPG Gridcentric package signing public key. cat >$KEYFILE </dev/null 2>&1; then # Import the package key and add repos. apt-key add $KEYFILE cat >/etc/apt/sources.list.d/reactor.list <<-EOF deb http://downloads.gridcentric.com/packages/reactor/reactor-core/precise gridcentric multiverse deb http://downloads.gridcentric.com/packages/cobaltclient/grizzly/precise gridcentric multiverse EOF # Update all repos since there may have been changes upstream since machine # was last updated. Failing to refresh the cache may prevent us from # fetching the latest version of python-software-properties, which in turn # may not have the latest cloud-archive repository info. apt-get update # Add Ubuntu Cloud Archive repo for novaclient apt-get -y install python-software-properties add-apt-repository -y cloud-archive:havana # Update all repos. apt-get update # Install novaclient here. apt-get -y install ubuntu-cloud-keyring apt-get -y install python-novaclient # Install zookeeper here. apt-get -y install zookeeperd # Install all packages. # (Deb packages come with soft dependencies). apt-get -y -o APT::Install-Recommends=1 install reactor-server apt-get -y -o APT::Install-Recommends=1 install reactor-manager elif rpm -ql coreutils >/dev/null 2>&1; then # Import the package key and add repos. rpm --import $KEYFILE cat >/etc/yum.repos.d/reactor.repo <<-EOF [reactor] name=Gridcentric Reactor baseurl=http://downloads.gridcentric.com/packages/reactor/reactor-core/centos/ gpgcheck=1 enabled=1 [cobaltclient] name=Cobalt Extension for novaclient baseurl=http://downloads.gridcentric.com/packages/cobaltclient/grizzly/centos/ gpgcheck=1 enabled=1 EOF # Add requisite EPEL repos, if not already installed. # This is the EPEL public key. You can verify at # https://fedoraproject.org/static/0608B895.txt cat >$KEYFILE <<-EOF -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.5 (GNU/Linux) mQINBEvSKUIBEADLGnUj24ZVKW7liFN/JA5CgtzlNnKs7sBg7fVbNWryiE3URbn1 JXvrdwHtkKy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NR27fVzCANlEPljsHA+3Ez4F7uboF p0OOEov4Yyi4BEbgqZnthTG4ub9nyiupIZ3ckPHr3nVcDUGcL6lQD/nkmNVIeLYP x1uHPOSlWfuojAYgzRH6LL7Idg4FHHBA0to7FW8dQXFIOyNiJFAOT2j8P5+tVdq8 wB0PDSH8yRpn4HdJ9RYquau4OkjluxOWf0uRaS//SUcCZh+1/KBEOmcvBHYRZA5J l/nakCgxGb2paQOzqqpOcHKvlyLuzO5uybMXaipLExTGJXBlXrbbASfXa/yGYSAG iVrGz9CE6676dMlm8F+s3XXE13QZrXmjloc6jwOljnfAkjTGXjiB7OULESed96MR XtfLk0W5Ab9pd7tKDR6QHI7rgHXfCopRnZ2VVQ== =V/6I -----END PGP PUBLIC KEY BLOCK----- EOF rpm -qi gpg-pubkey-0608b895-4bd22942 > /dev/null 2>&1 || rpm --import $KEYFILE rpm -qa | grep -q epel-release || rpm -Uvh \ http://dl.fedoraproject.org/pub/epel/6/`uname -m`/epel-release-6-8.noarch.rpm # Ugh. The packages on centos are broken for pyramid and zope. # This is really annoying. We have to ensure that the current # version is up-to-date and then allow easy_install to install # an upgraded version. yum -y install python-webob1.0 easy_install webob yum -y install python-zope-interface easy_install --upgrade zope.interface # Install zookeeper here. yum -y install zookeeper # Loadbalancer soft dependencies. yum -y install nginx haproxy dnsmasq socat # Cloud connection soft dependencies. yum -y install python-novaclient cobalt-novaclient # Reactor core (previous packages should be done). yum -y install reactor-server yum -y install reactor-manager else # Unknown system! exit 2 fi # Save copies of replaced files. BACKUP_DATE=$(date +%Y%m%d%H%M%S) # Setup nginx, if it's installed. if [ -d /etc/nginx ]; then # Ensure necessary directories exist. mkdir -p /var/log/nginx mkdir -p /etc/nginx/conf.d mkdir -p /etc/nginx/sites-enabled # Clear out the default site, if it's there. rm -f /etc/nginx/sites-enabled/default rm -f /etc/nginx/conf.d/default.conf if [ -f /etc/nginx/nginx.conf ]; then # Save the original configuration. mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.$BACKUP_DATE fi # Install the reactor configuration. cp -a /etc/reactor/example/nginx/nginx.conf /etc/nginx/nginx.conf fi # Save the haproxy config, if it's installed. if [ -f /etc/haproxy/haproxy.cfg ]; then cp -a /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.$BACKUP_DATE fi # Check that haproxy is enabled. if [ -f /etc/default/haproxy ]; then if grep ENABLED /etc/default/haproxy >/dev/null; then # Ensure that the haproxy init script is enabled. sed -e 's/ENABLED=.*/ENABLED=1/' -i /etc/default/haproxy fi fi # Save the dnsmasq config, if it's installed. if [ -f /etc/dnsmasq.conf ]; then cp -a /etc/dnsmasq.conf /etc/dnsmasq.conf.$BACKUP_DATE fi # Important: defaults should only be run for one reactor in a clustered setup. reactor-defaults