3 # Read configuration files
4 ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt)
5 DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt)
6 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
7 GERRIT_BRANCH=$(cat /opt/config/gerrit_branch.txt)
8 AAI_INSTANCE=$(cat /opt/config/aai_instance.txt)
9 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
10 CODE_REPO=$(cat /opt/config/remote_repo.txt)
11 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
12 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
14 if [ $HTTP_PROXY != "no_proxy" ]
16 export http_proxy=$HTTP_PROXY
17 export https_proxy=$HTTPS_PROXY
20 # Add host name to /etc/host to avoid warnings in openstack images
21 if [[ $CLOUD_ENV != "rackspace" ]]
23 echo 127.0.0.1 $(hostname) >> /etc/hosts
25 # Allow remote login as root
26 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
27 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
30 # Set private IP in /etc/network/interfaces manually in the presence of public interface
31 # Some VM images don't add the private interface automatically, we have to do it during the component installation
32 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
34 LOCAL_IP=$(cat /opt/config/local_ip_addr.txt)
35 CIDR=$(cat /opt/config/oam_network_cidr.txt)
36 BITMASK=$(echo $CIDR | cut -d"/" -f2)
38 # Compute the netmask based on the network cidr
39 if [[ $BITMASK == "8" ]]
42 elif [[ $BITMASK == "16" ]]
45 elif [[ $BITMASK == "24" ]]
50 echo "auto eth1" >> /etc/network/interfaces
51 echo "iface eth1 inet static" >> /etc/network/interfaces
52 echo " address $LOCAL_IP" >> /etc/network/interfaces
53 echo " netmask $NETMASK" >> /etc/network/interfaces
54 echo " mtu $MTU" >> /etc/network/interfaces
58 # Download dependencies
59 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
60 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
62 apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate make
64 # Download scripts from Nexus
65 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip aai_vm_init.sh > /opt/aai_vm_init.sh
66 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip aai_serv.sh > /opt/aai_serv.sh
67 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip imagetest.sh > /opt/imagetest.sh
68 chmod +x /opt/imagetest.sh
69 chmod +x /opt/aai_vm_init.sh
70 chmod +x /opt/aai_serv.sh
71 mv /opt/aai_serv.sh /etc/init.d
72 update-rc.d aai_serv.sh defaults
74 # Download and install docker-engine and docker-compose
75 echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
77 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
78 apt-get install -y --allow-unauthenticated docker-engine
81 curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
82 chmod +x /opt/docker/docker-compose
84 # 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
86 if [ -s /opt/config/dns_ip_addr.txt ]
88 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) "
90 if [ -s /opt/config/external_dns.txt ]
92 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) "
94 echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker
96 cp /lib/systemd/system/docker.service /etc/systemd/system
97 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
98 if [ $HTTP_PROXY != "no_proxy" ]
103 service docker restart
105 # DNS IP address configuration
106 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
109 # Run docker containers
111 git clone -b $GERRIT_BRANCH --single-branch $CODE_REPO
113 if [[ $AAI_INSTANCE == "aai_instance_1" ]]
115 mkdir -p /opt/aai/logroot/AAI-RESOURCES
116 mkdir -p /opt/aai/logroot/AAI-TRAVERSAL
117 mkdir -p /opt/aai/logroot/AAI-ML
118 mkdir -p /opt/aai/logroot/AAI-SDB
119 mkdir -p /opt/aai/logroot/AAI-DRMS
120 mkdir -p /opt/aai/logroot/AAI-UI
121 chown -R 999:999 /opt/aai/logroot/AAI-RESOURCES /opt/aai/logroot/AAI-TRAVERSAL