Add floating IPs for DCAE
[demo.git] / boot / dns_install.sh
1 #!/bin/bash
2
3 # Read configuration files
4 NEXUS_REPO=$(cat /opt/config/nexus_repo.txt)
5 ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt)
6 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
7
8 # Add host name to /etc/host to avoid warnings in openstack images
9 if [[ $CLOUD_ENV == "openstack" ]]
10 then
11         echo 127.0.0.1 $(hostname) >> /etc/hosts
12 fi
13
14 # Download dependencies
15 add-apt-repository -y ppa:openjdk-r/ppa
16 apt-get update
17 apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk bind9 bind9utils bind9-doc ntp ntpdate
18
19 # Set the Bind configuration file name based on the deployment environment
20 if [[ $CLOUD_ENV == "openstack" ]]
21 then
22         ZONE_FILE="bind_zones"
23         OPTIONS_FILE="bind_options"
24 else
25         ZONE_FILE="db_simpledemo_openecomp_org"
26         OPTIONS_FILE="named.conf.options"
27 fi
28
29 # Download script
30 mkdir /etc/bind/zones
31 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/$ZONE_FILE -o /etc/bind/zones/db.simpledemo.openecomp.org
32 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/$OPTIONS_FILE -o /etc/bind/named.conf.options
33 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/named.conf.local -o /etc/bind/named.conf.local
34
35 # Set the private IP address of each ONAP VM in the Bind configuration in OpenStack deployments
36 if [[ $CLOUD_ENV == "openstack" ]]
37 then
38         sed -i "s/dns_ip_addr/"$(cat /opt/config/dns_ip_addr.txt)"/g" /etc/bind/named.conf.options
39         sed -i "s/aai_ip_addr/"$(cat /opt/config/aai_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
40         sed -i "s/appc_ip_addr/"$(cat /opt/config/appc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
41         sed -i "s/dcae_ip_addr/"$(cat /opt/config/dcae_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
42         sed -i "s/dns_ip_addr/"$(cat /opt/config/dns_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
43         sed -i "s/mso_ip_addr/"$(cat /opt/config/mso_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
44         sed -i "s/mr_ip_addr/"$(cat /opt/config/mr_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
45         sed -i "s/policy_ip_addr/"$(cat /opt/config/policy_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
46         sed -i "s/portal_ip_addr/"$(cat /opt/config/portal_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
47         sed -i "s/robot_ip_addr/"$(cat /opt/config/robot_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
48         sed -i "s/sdc_ip_addr/"$(cat /opt/config/sdc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
49         sed -i "s/sdnc_ip_addr/"$(cat /opt/config/sdnc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
50         sed -i "s/vid_ip_addr/"$(cat /opt/config/vid_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
51         sed -i "s/dcae_coll_ip_addr/"$(cat /opt/config/dcae_coll_float_ip.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
52 fi
53
54 # Configure Bind
55 modprobe ip_gre
56 sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
57 service bind9 restart