2 #############################################################################
4 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 #############################################################################
21 # Read configuration files
22 NEXUS_REPO=$(cat /opt/config/nexus_repo.txt)
23 ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt)
24 DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt)
25 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
26 EXTERNAL_DNS=$(cat /opt/config/external_dns.txt)
27 MAC_ADDR=$(cat /opt/config/mac_addr.txt)
29 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
31 if [[ $CLOUD_ENV != "rackspace" ]]
33 # Add host name to /etc/host to avoid warnings in openstack images
34 echo "127.0.0.1 $(hostname)" >> /etc/hosts
36 # Allow remote login as root
37 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
38 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
41 # Download dependencies
42 #echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
43 #echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
45 #apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget make openjdk-8-jdk git ntp ntpdate python python-pip
46 apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget git ntp ntpdate python python-pip
48 # Download scripts from Nexus
49 if [ ! -e /opt/dcae2_vm_init.sh ]; then
50 curl -k "$NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/dcae2_vm_init.sh" -o /opt/dcae2_vm_init.sh
52 curl -k "$NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/dcae2_serv.sh" -o /opt/dcae2_serv.sh
53 chmod +x /opt/dcae2_vm_init.sh
54 chmod +x /opt/dcae2_serv.sh
55 mv /opt/dcae2_serv.sh /etc/init.d
56 update-rc.d dcae2_serv.sh defaults
58 # Download and install docker-engine and docker-compose
59 echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
61 apt-get install -y "linux-image-extra-$(uname -r)" linux-image-extra-virtual jq
62 apt-get install -y --allow-unauthenticated docker-engine
65 curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" > /opt/docker/docker-compose
66 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
70 # need to know the external DNS IP
72 if [ -s /opt/config/dns_ip_addr.txt ]
74 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) "
76 if [ -s /opt/config/external_dns.txt ]
78 DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) "
80 echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\"" >> /etc/default/docker
82 cp /lib/systemd/system/docker.service /etc/systemd/system
83 sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service
84 sed -i "/ExecStart/s/$/ -H tcp:\/\/0.0.0.0:2376 --raw-logs/g" /etc/systemd/system/docker.service
85 systemctl daemon-reload
86 service docker restart
88 # add hostname aliases
89 echo "$(cat /opt/config/dcae_ip_addr.txt) consul" >>/etc/hosts
90 echo "$(cat /opt/config/dcae_ip_addr.txt) dockerhost" >>/etc/hosts
92 # DNS IP address configuration
93 echo "nameserver $DNS_IP_ADDR" >> /etc/resolvconf/resolv.conf.d/head
97 # prepare the configurations needed by DCAEGEN2 installer
98 rm -rf /opt/app/config
99 mkdir -p /opt/app/config
103 sed -e 's/\\n/\n/g' /opt/config/priv_key | sed -e 's/^[ \t]*//g; s/[ \t]*$//g' > /opt/app/config/key
104 chmod 777 /opt/app/config/key
106 # move keystone url file
107 #cp /opt/config/keystone_url.txt /opt/app/config/keystone_url.txt