32c6167f4af936fb4c4e4b0f35fba3c140044b93
[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
12         # Allow remote login as root
13         mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
14         cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
15
16         MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
17
18         VSN_PRIVATE_IP_O=$(cat /opt/config/vsn_private_ip_0.txt)
19         echo "auto eth1" >> /etc/network/interfaces
20         echo "iface eth1 inet static" >> /etc/network/interfaces
21         echo "    address $VSN_PRIVATE_IP_O" >> /etc/network/interfaces
22         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
23         echo "    mtu $MTU" >> /etc/network/interfaces
24
25         VSN_PRIVATE_IP_1=$(cat /opt/config/vsn_private_ip_1.txt)
26         echo "auto eth2" >> /etc/network/interfaces
27         echo "iface eth2 inet static" >> /etc/network/interfaces
28         echo "    address $VSN_PRIVATE_IP_1" >> /etc/network/interfaces
29         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
30         echo "    mtu $MTU" >> /etc/network/interfaces
31
32         ifup eth1
33         ifup eth2
34 fi
35
36 # Download required dependencies
37 add-apt-repository -y ppa:openjdk-r/ppa
38 apt-get update
39 apt-get install -y make wget openjdk-8-jdk apt-transport-https ca-certificates darkstat
40
41 # Configure and run Darkstat
42 sed -i "s/START_DARKSTAT=.*/START_DARKSTAT=yes/g" /etc/darkstat/init.cfg
43 sed -i "s/INTERFACE=.*/INTERFACE=\"-i eth1\"/g" /etc/darkstat/init.cfg
44 /etc/init.d/darkstat start
45
46 # Download scripts for virtual sink
47 cd /opt
48 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vfw/$INSTALL_SCRIPT_VERSION/v_sink_init.sh
49 wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vfw/$INSTALL_SCRIPT_VERSION/vsink.sh
50 chmod +x v_sink_init.sh
51 chmod +x vsink.sh
52
53 # Run instantiation script
54 mv vsink.sh /etc/init.d
55 update-rc.d vsink.sh defaults
56 ./v_sink_init.sh