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)
9 # Add host name to /etc/host to avoid warnings in openstack images
10 if [[ $CLOUD_ENV != "rackspace" ]]
12 echo 127.0.0.1 $(hostname) >> /etc/hosts
14 # Allow remote login as root
15 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
16 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
19 # Set private IP in /etc/network/interfaces manually in the presence of public interface
20 # Some VM images don't add the private interface automatically, we have to do it during the component installation
21 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
23 LOCAL_IP=$(cat /opt/config/local_ip_addr.txt)
24 CIDR=$(cat /opt/config/oam_network_cidr.txt)
25 BITMASK=$(echo $CIDR | cut -d"/" -f2)
27 # Compute the netmask based on the network cidr
28 if [[ $BITMASK == "8" ]]
31 elif [[ $BITMASK == "16" ]]
34 elif [[ $BITMASK == "24" ]]
39 echo "auto eth1" >> /etc/network/interfaces
40 echo "iface eth1 inet static" >> /etc/network/interfaces
41 echo " address $LOCAL_IP" >> /etc/network/interfaces
42 echo " netmask $NETMASK" >> /etc/network/interfaces
46 # Download dependencies
47 add-apt-repository -y ppa:openjdk-r/ppa
49 apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate
51 # Download scripts from Nexus
52 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/aai_vm_init.sh -o /opt/aai_vm_init.sh
53 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/aai_serv.sh -o /opt/aai_serv.sh
54 chmod +x /opt/aai_vm_init.sh
55 chmod +x /opt/aai_serv.sh
56 mv /opt/aai_serv.sh /etc/init.d
57 update-rc.d aai_serv.sh defaults
59 # Download and install docker-engine and docker-compose
60 echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
62 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
63 apt-get install -y --allow-unauthenticated docker-engine
66 curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
67 chmod +x /opt/docker/docker-compose
69 # 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
70 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
72 if [ -s /opt/config/external_dns.txt ]
74 echo "DOCKER_OPTS=\"--dns $(cat /opt/config/external_dns.txt) --mtu=$MTU\"" >> /etc/default/docker
76 echo "DOCKER_OPTS=\"--mtu=$MTU\"" >> /etc/default/docker
79 cp /lib/systemd/system/docker.service /etc/systemd/system
80 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
81 service docker restart
83 # DNS IP address configuration
84 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
87 # Run docker containers
88 mkdir -p /opt/openecomp/aai/logs
89 mkdir -p /opt/openecomp/aai/data