Assign public interface to vFW in OpenStack
[demo.git] / vnfs / vFW / scripts / v_sink_install.sh
1 #!/bin/bash
2
3 REPO_URL_BLOB=$(cat /opt/config/repo_url_blob.txt)
4 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
5 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
6
7 # OpenStack network configuration
8 if [[ $CLOUD_ENV == "openstack" ]]
9 then
10         echo 127.0.0.1 $(hostname) >> /etc/hosts
11         MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
12
13         VSN_PRIVATE_IP_O=$(cat /opt/config/vsn_private_ip_0.txt)
14         echo "auto eth1" >> /etc/network/interfaces
15         echo "iface eth1 inet static" >> /etc/network/interfaces
16         echo "    address $VSN_PRIVATE_IP_O" >> /etc/network/interfaces
17         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
18         echo "    mtu $MTU" >> /etc/network/interfaces
19
20         VSN_PRIVATE_IP_1=$(cat /opt/config/vsn_private_ip_1.txt)
21         echo "auto eth2" >> /etc/network/interfaces
22         echo "iface eth2 inet static" >> /etc/network/interfaces
23         echo "    address $VSN_PRIVATE_IP_1" >> /etc/network/interfaces
24         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
25         echo "    mtu $MTU" >> /etc/network/interfaces
26
27         ifup eth1
28         ifup eth2
29 fi
30
31 # Download required dependencies
32 add-apt-repository -y ppa:openjdk-r/ppa
33 apt-get update
34 apt-get install -y make wget openjdk-8-jdk apt-transport-https ca-certificates darkstat
35
36 # Configure and run Darkstat
37 sed -i "s/START_DARKSTAT=.*/START_DARKSTAT=yes/g" /etc/darkstat/init.cfg
38 sed -i "s/INTERFACE=.*/INTERFACE=\"-i eth1\"/g" /etc/darkstat/init.cfg
39 /etc/init.d/darkstat start
40
41 # Download scripts for virtual sink
42 cd /opt
43 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vfw/$INSTALL_SCRIPT_VERSION/v_sink_init.sh
44 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vfw/$INSTALL_SCRIPT_VERSION/vsink.sh
45 chmod +x v_sink_init.sh
46 chmod +x vsink.sh
47
48 # Run instantiation script
49 mv vsink.sh /etc/init.d
50 update-rc.d vsink.sh defaults
51 ./v_sink_init.sh