enable no floating IPs in install scripts
[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 if [[ $CLOUD_ENV != "rackspace" ]]
9 then
10         # Add host name to /etc/host to avoid warnings in openstack images
11         echo 127.0.0.1 $(hostname) >> /etc/hosts
12
13         # Set the Bind configuration file name based on the deployment environment
14         ZONE_FILE="bind_zones"
15         OPTIONS_FILE="bind_options"
16 else
17         ZONE_FILE="db_simpledemo_openecomp_org"
18         OPTIONS_FILE="named.conf.options"
19 fi
20
21 # Set private IP in /etc/network/interfaces manually in the presence of public interface
22 # Some VM images don't add the private interface automatically, we have to do it during the component installation
23 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
24 then
25         LOCAL_IP=$(cat /opt/config/dns_ip_addr.txt)
26         CIDR=$(cat /opt/config/oam_network_cidr.txt)
27         BITMASK=$(echo $CIDR | cut -d"/" -f2)
28
29         # Compute the netmask based on the network cidr
30         if [[ $BITMASK == "8" ]]
31         then
32                 NETMASK=255.0.0.0
33         elif [[ $BITMASK == "16" ]]
34         then
35                 NETMASK=255.255.0.0
36         elif [[ $BITMASK == "24" ]]
37         then
38                 NETMASK=255.255.255.0
39         fi
40
41         echo "auto eth1" >> /etc/network/interfaces
42         echo "iface eth1 inet static" >> /etc/network/interfaces
43         echo "    address $LOCAL_IP" >> /etc/network/interfaces
44         echo "    netmask $NETMASK" >> /etc/network/interfaces
45         ifup eth1
46 fi
47
48 # Download dependencies
49 add-apt-repository -y ppa:openjdk-r/ppa
50 apt-get update
51 apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk bind9 bind9utils bind9-doc ntp ntpdate
52
53 # Download script
54 mkdir /etc/bind/zones
55 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/$ZONE_FILE -o /etc/bind/zones/db.simpledemo.openecomp.org
56 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/$OPTIONS_FILE -o /etc/bind/named.conf.options
57 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/named.conf.local -o /etc/bind/named.conf.local
58
59 # Set the private IP address of each ONAP VM in the Bind configuration in OpenStack deployments
60 if [[ $CLOUD_ENV != "rackspace" ]]
61 then
62         sed -i "s/dns_ip_addr/"$(cat /opt/config/dns_ip_addr.txt)"/g" /etc/bind/named.conf.options
63         sed -i "s/aai_ip_addr/"$(cat /opt/config/aai_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
64         sed -i "s/appc_ip_addr/"$(cat /opt/config/appc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
65         sed -i "s/dcae_ip_addr/"$(cat /opt/config/dcae_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
66         sed -i "s/dns_ip_addr/"$(cat /opt/config/dns_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
67         sed -i "s/mso_ip_addr/"$(cat /opt/config/mso_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
68         sed -i "s/mr_ip_addr/"$(cat /opt/config/mr_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
69         sed -i "s/policy_ip_addr/"$(cat /opt/config/policy_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
70         sed -i "s/portal_ip_addr/"$(cat /opt/config/portal_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
71         sed -i "s/robot_ip_addr/"$(cat /opt/config/robot_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
72         sed -i "s/sdc_ip_addr/"$(cat /opt/config/sdc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
73         sed -i "s/sdnc_ip_addr/"$(cat /opt/config/sdnc_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
74         sed -i "s/vid_ip_addr/"$(cat /opt/config/vid_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
75         sed -i "s/dcae_coll_ip_addr/"$(cat /opt/config/dcae_coll_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org
76 fi
77
78 # Configure Bind
79 modprobe ip_gre
80 sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
81 service bind9 restart