3 # Read configuration files
4 NEXUS_REPO=$(cat /opt/config/nexus_repo.txt)
5 ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt)
6 DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt)
7 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
8 GERRIT_BRANCH=$(cat /opt/config/gerrit_branch.txt)
10 # Add host name to /etc/host to avoid warnings in openstack images
11 if [[ $CLOUD_ENV != "rackspace" ]]
13 echo 127.0.0.1 $(hostname) >> /etc/hosts
15 # Allow remote login as root
16 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
17 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
20 # Set private IP in /etc/network/interfaces manually in the presence of public interface
21 # Some VM images don't add the private interface automatically, we have to do it during the component installation
22 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
24 LOCAL_IP=$(cat /opt/config/local_ip_addr.txt)
25 CIDR=$(cat /opt/config/oam_network_cidr.txt)
26 BITMASK=$(echo $CIDR | cut -d"/" -f2)
28 # Compute the netmask based on the network cidr
29 if [[ $BITMASK == "8" ]]
32 elif [[ $BITMASK == "16" ]]
35 elif [[ $BITMASK == "24" ]]
40 echo "auto eth1" >> /etc/network/interfaces
41 echo "iface eth1 inet static" >> /etc/network/interfaces
42 echo " address $LOCAL_IP" >> /etc/network/interfaces
43 echo " netmask $NETMASK" >> /etc/network/interfaces
47 # Download dependencies
48 add-apt-repository -y ppa:openjdk-r/ppa
50 apt-get install -y apt-transport-https ca-certificates wget make openjdk-8-jdk git ntp ntpdate
52 # Download scripts from Nexus
53 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/mr_vm_init.sh -o /opt/mr_vm_init.sh
54 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/mr_serv.sh -o /opt/mr_serv.sh
55 chmod +x /opt/mr_vm_init.sh
56 chmod +x /opt/mr_serv.sh
57 mv /opt/mr_serv.sh /etc/init.d
58 update-rc.d mr_serv.sh defaults
60 # Download and install docker-engine and docker-compose
61 echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
63 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
64 apt-get install -y --allow-unauthenticated docker-engine
67 curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
68 chmod +x /opt/docker/docker-compose
70 # Set the MTU size of docker containers to the minimum MTU size supported by vNICs. OpenStack deployments may need to know the external DNS IP
71 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
73 if [ -s /opt/config/external_dns.txt ]
75 echo "DOCKER_OPTS=\"--dns $(cat /opt/config/external_dns.txt) --mtu=$MTU\"" >> /etc/default/docker
77 echo "DOCKER_OPTS=\"--mtu=$MTU\"" >> /etc/default/docker
80 cp /lib/systemd/system/docker.service /etc/systemd/system
81 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
82 service docker restart
84 # DNS IP address configuration
85 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
88 # Clone Gerrit repository and run docker containers
90 git clone -b $GERRIT_BRANCH --single-branch http://gerrit.onap.org/r/dcae/demo/startup/message-router.git dcae-startup-vm-message-router