enable no floating IPs in install scripts
[demo.git] / boot / aai_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 DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt)
7 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
8
9 # Add host name to /etc/host to avoid warnings in openstack images
10 if [[ $CLOUD_ENV != "rackspace" ]]
11 then
12         echo 127.0.0.1 $(hostname) >> /etc/hosts
13 fi
14
15 # Set private IP in /etc/network/interfaces manually in the presence of public interface
16 # Some VM images don't add the private interface automatically, we have to do it during the component installation
17 if [[ $CLOUD_ENV == "openstack_nofloat" ]]
18 then
19         LOCAL_IP=$(cat /opt/config/local_ip_addr.txt)
20         CIDR=$(cat /opt/config/oam_network_cidr.txt)
21         BITMASK=$(echo $CIDR | cut -d"/" -f2)
22
23         # Compute the netmask based on the network cidr
24         if [[ $BITMASK == "8" ]]
25         then
26                 NETMASK=255.0.0.0
27         elif [[ $BITMASK == "16" ]]
28         then
29                 NETMASK=255.255.0.0
30         elif [[ $BITMASK == "24" ]]
31         then
32                 NETMASK=255.255.255.0
33         fi
34
35         echo "auto eth1" >> /etc/network/interfaces
36         echo "iface eth1 inet static" >> /etc/network/interfaces
37         echo "    address $LOCAL_IP" >> /etc/network/interfaces
38         echo "    netmask $NETMASK" >> /etc/network/interfaces
39         ifup eth1
40 fi
41
42 # Download dependencies
43 add-apt-repository -y ppa:openjdk-r/ppa
44 apt-get update
45 apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate
46
47 # Download scripts from Nexus
48 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/aai_vm_init.sh -o /opt/aai_vm_init.sh
49 curl -k $NEXUS_REPO/org.openecomp.demo/boot/$ARTIFACTS_VERSION/aai_serv.sh -o /opt/aai_serv.sh
50 chmod +x /opt/aai_vm_init.sh
51 chmod +x /opt/aai_serv.sh
52 mv /opt/aai_serv.sh /etc/init.d
53 update-rc.d aai_serv.sh defaults
54
55 # Download and install docker-engine and docker-compose
56 echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
57 apt-get update
58 apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
59 apt-get install -y --allow-unauthenticated docker-engine
60
61 mkdir /opt/docker
62 curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
63 chmod +x /opt/docker/docker-compose
64
65 # DNS IP address configuration
66 echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head
67 resolvconf -u
68
69 # Run docker containers
70 mkdir -p /opt/openecomp/aai/logs
71 mkdir -p /opt/openecomp/aai/data
72 cd /opt
73 ./aai_vm_init.sh