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 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
8 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
9 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
11 if [ $HTTP_PROXY != "no_proxy" ]
13 export http_proxy=$HTTP_PROXY
14 export https_proxy=$HTTPS_PROXY
17 # Short-term fix to get around MSO to SO name change
18 cp /opt/config/so_ip_addr.txt /opt/config/mso_ip_addr.txt
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
59 apt-get install -y apt-transport-https ca-certificates wget git ntp ntpdate make
61 # Download scripts from Nexus
62 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot_vm_init.sh > /opt/robot_vm_init.sh
63 chmod +x /opt/robot_vm_init.sh
64 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot_serv.sh > /opt/robot_serv.sh
65 chmod +x /opt/robot_serv.sh
66 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip imagetest.sh > /opt/imagetest.sh
67 chmod +x /opt/imagetest.sh
69 mkdir -p /opt/eteshare/config
70 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot/integration_preload_parameters.py > /opt/eteshare/config/integration_preload_parameters.py
71 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot/integration_robot_properties.py > /opt/eteshare/config/integration_robot_properties.py
72 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot/vm_config2robot.sh > /opt/eteshare/config/vm_config2robot.sh
73 chmod +x /opt/eteshare/config/vm_config2robot.sh
74 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot/ete.sh > /opt/ete.sh
76 unzip -p -j /opt/boot-$ARTIFACTS_VERSION.zip robot/demo.sh > /opt/demo.sh
79 mkdir -p /opt/eteshare/logs
81 cp /opt/robot_serv.sh /etc/init.d
82 update-rc.d robot_serv.sh defaults
84 # Download and install docker-engine
85 echo "deb https://apt.dockerproject.org/repo ubuntu-$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/docker.list
87 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
88 apt-get install -y --allow-unauthenticated docker-engine
90 # 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
92 if [ -s /opt/config/dns_ip_addr.txt ]
94 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) "
96 if [ -s /opt/config/external_dns.txt ]
98 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) "
100 echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker
102 cp /lib/systemd/system/docker.service /etc/systemd/system
103 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
104 if [ $HTTP_PROXY != "no_proxy" ]
109 service docker restart
111 # DNS IP address configuration
112 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
116 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
117 if [[ $CLOUD_ENV != "rackspace" ]]
119 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
120 grub-mkconfig -o /boot/grub/grub.cfg
121 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
122 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
123 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
124 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
128 # Run docker containers. For openstack Ubuntu 16.04 images this will run as a service after the VM has restarted