Fix issues with the MTU size in vFW/vLB
[demo.git] / vnfs / vLB / scripts / v_lb_install.sh
1 #!/bin/bash
2
3 REPO_URL_BLOB=$(cat /opt/config/repo_url_blob.txt)
4 REPO_URL_ARTIFACTS=$(cat /opt/config/repo_url_artifacts.txt)
5 DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
6 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
7 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
8
9 # OpenStack network configuration
10 if [[ $CLOUD_ENV == "openstack" ]]
11 then
12         echo 127.0.0.1 $(hostname) >> /etc/hosts
13
14         # Allow remote login as root
15         mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
16         cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
17
18         MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
19
20         VLB_PRIVATE_IP_O=$(cat /opt/config/local_private_ipaddr.txt)
21         echo "auto eth1" >> /etc/network/interfaces
22         echo "iface eth1 inet static" >> /etc/network/interfaces
23         echo "    address $VLB_PRIVATE_IP_O" >> /etc/network/interfaces
24         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
25         echo "    mtu $MTU" >> /etc/network/interfaces
26
27         VLB_PRIVATE_IP_1=$(cat /opt/config/oam_private_ipaddr.txt)
28         echo "auto eth2" >> /etc/network/interfaces
29         echo "iface eth2 inet static" >> /etc/network/interfaces
30         echo "    address $VLB_PRIVATE_IP_1" >> /etc/network/interfaces
31         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
32         echo "    mtu $MTU" >> /etc/network/interfaces
33
34         ifup eth1
35         ifup eth2
36 fi
37
38 # Download required dependencies
39 add-apt-repository -y ppa:openjdk-r/ppa
40 apt-get update
41 apt-get install -y make gcc wget openjdk-8-jdk bridge-utils libcurl4-openssl-dev apt-transport-https ca-certificates
42 sleep 1
43
44 # Download vLB demo code for load balancer
45 mkdir /opt/config
46 mkdir /opt/FDserver
47 cd /opt
48
49 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/v_lb_init.sh
50 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/vlb.sh
51 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/dnsmembership.sh
52 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/add_dns.sh
53 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/remove_dns.sh
54 wget $REPO_URL_ARTIFACTS/org/openecomp/demo/vnf/vlb/dns-manager/$DEMO_ARTIFACTS_VERSION/dns-manager-$DEMO_ARTIFACTS_VERSION.jar
55 wget $REPO_URL_ARTIFACTS/org/openecomp/demo/vnf/ves/ves/$DEMO_ARTIFACTS_VERSION/ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
56 wget $REPO_URL_ARTIFACTS/org/openecomp/demo/vnf/ves/ves_vlb_reporting/$DEMO_ARTIFACTS_VERSION/ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
57
58 tar -zxvf ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
59 mv ves-$DEMO_ARTIFACTS_VERSION VES
60 tar -zxvf ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
61 mv ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION VESreporting_vLB
62
63 mv VESreporting_vLB /opt/VES/code/evel_training/VESreporting
64 mv dns-manager-$DEMO_ARTIFACTS_VERSION.jar /opt/FDserver/dns-manager-$DEMO_ARTIFACTS_VERSION.jar
65 mv dnsmembership.sh /opt/FDserver/dnsmembership.sh
66 mv add_dns.sh /opt/FDserver/add_dns.sh
67 mv remove_dns.sh /opt/FDserver/remove_dns.sh
68 rm *.tar.gz
69
70 chmod +x v_lb_init.sh
71 chmod +x vlb.sh
72 chmod +x /opt/VES/code/evel_training/VESreporting/go-client.sh
73 chmod +x /opt/FDserver/dnsmembership.sh
74 chmod +x /opt/FDserver/add_dns.sh
75 chmod +x /opt/FDserver/remove_dns.sh
76
77 # Create a file with public IP of the VM if it doesn't exist. This is for VMs directly attached to the external network.
78 if [ ! -e /opt/config/local_public_ipaddr.txt ]
79 then
80         IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
81         echo $IP_ADDRESS > /opt/config/local_public_ipaddr.txt
82 fi
83
84 # Install VPP
85 export UBUNTU="trusty"
86 export RELEASE=".stable.1609"
87 rm /etc/apt/sources.list.d/99fd.io.list
88 echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io$RELEASE.ubuntu.$UBUNTU.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
89 apt-get update
90 apt-get install -y vpp vpp-dpdk-dkms vpp-lib vpp-dbg vpp-plugins vpp-dev
91 sleep 1
92
93 # Install VES
94 cd /opt/VES/bldjobs/
95 make clean
96 make
97 sleep 1
98
99 # Run instantiation script
100 cd /opt
101 mv vlb.sh /etc/init.d
102 update-rc.d vlb.sh defaults
103 ./v_lb_init.sh