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)
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 HEAT_CODE_REPO=http://gerrit.onap.org/r/demo.git
13 # Short-term fix to get around MSO to SO name change
14 cp /opt/config/so_ip_addr.txt /opt/config/mso_ip_addr.txt
16 # Add host name to /etc/host to avoid warnings in openstack images
17 if [[ $CLOUD_ENV != "rackspace" ]]
19 echo 127.0.0.1 $(hostname) >> /etc/hosts
21 # Allow remote login as root
22 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
23 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
26 # Set private IP in /etc/network/interfaces manually in the presence of public interface
27 # Some VM images don't add the private interface automatically, we have to do it during the component installation
28 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
30 LOCAL_IP=$(cat /opt/config/local_ip_addr.txt)
31 CIDR=$(cat /opt/config/oam_network_cidr.txt)
32 BITMASK=$(echo $CIDR | cut -d"/" -f2)
34 # Compute the netmask based on the network cidr
35 if [[ $BITMASK == "8" ]]
38 elif [[ $BITMASK == "16" ]]
41 elif [[ $BITMASK == "24" ]]
46 echo "auto eth1" >> /etc/network/interfaces
47 echo "iface eth1 inet static" >> /etc/network/interfaces
48 echo " address $LOCAL_IP" >> /etc/network/interfaces
49 echo " netmask $NETMASK" >> /etc/network/interfaces
50 echo " mtu $MTU" >> /etc/network/interfaces
54 # Download dependencies
55 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
56 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
58 apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate make
60 # Download scripts from Nexus
61 curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/robot_vm_init.sh -o /opt/robot_vm_init.sh
62 curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/robot_serv.sh -o /opt/robot_serv.sh
63 chmod +x /opt/robot_vm_init.sh
64 chmod +x /opt/robot_serv.sh
65 mv /opt/robot_serv.sh /etc/init.d
66 update-rc.d robot_serv.sh defaults
68 # Download and install docker-engine and docker-compose
69 echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
71 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
72 apt-get install -y --allow-unauthenticated docker-engine
75 curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
76 chmod +x /opt/docker/docker-compose
78 # 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
80 if [ -s /opt/config/dns_ip_addr.txt ]
82 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) "
84 if [ -s /opt/config/external_dns.txt ]
86 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) "
88 echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker
90 cp /lib/systemd/system/docker.service /etc/systemd/system
91 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
92 service docker restart
94 # DNS IP address configuration
95 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
98 # Clone Gerrit repository
99 mkdir -p /opt/eteshare/logs
100 mkdir -p /opt/eteshare/config
102 git clone -b $GERRIT_BRANCH --single-branch $CODE_REPO testsuite/properties
103 git clone -b $GERRIT_BRANCH --single-branch $HEAT_CODE_REPO demo
105 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
106 if [[ $CLOUD_ENV != "rackspace" ]]
108 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
109 grub-mkconfig -o /boot/grub/grub.cfg
110 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
111 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
112 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
113 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
117 # Run docker containers. For openstack Ubuntu 16.04 images this will run as a service after the VM has restarted