3 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
4 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
6 # Convert Network CIDR to Netmask
8 # Number of args to shift, 255..255, first non-255 byte, zeroes
9 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
10 [ $1 -gt 1 ] && shift $1 || shift
11 echo ${1-0}.${2-0}.${3-0}.${4-0}
14 # OpenStack network configuration
15 if [[ $CLOUD_ENV == "openstack" ]]
17 echo 127.0.0.1 $(hostname) >> /etc/hosts
19 # Allow remote login as root
20 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
21 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
23 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
25 IP=$(cat /opt/config/vsn_private_ip_0.txt)
26 BITS=$(cat /opt/config/protected_private_net_cidr.txt | cut -d"/" -f2)
27 NETMASK=$(cdr2mask $BITS)
28 echo "auto eth1" >> /etc/network/interfaces
29 echo "iface eth1 inet static" >> /etc/network/interfaces
30 echo " address $IP" >> /etc/network/interfaces
31 echo " netmask $NETMASK" >> /etc/network/interfaces
32 echo " mtu $MTU" >> /etc/network/interfaces
34 IP=$(cat /opt/config/vsn_private_ip_1.txt)
35 BITS=$(cat /opt/config/onap_private_net_cidr.txt | cut -d"/" -f2)
36 NETMASK=$(cdr2mask $BITS)
37 echo "auto eth2" >> /etc/network/interfaces
38 echo "iface eth2 inet static" >> /etc/network/interfaces
39 echo " address $IP" >> /etc/network/interfaces
40 echo " netmask $NETMASK" >> /etc/network/interfaces
41 echo " mtu $MTU" >> /etc/network/interfaces
47 # Download required dependencies
48 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
49 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
51 apt-get install --allow-unauthenticated -y make wget openjdk-8-jdk apt-transport-https ca-certificates darkstat
53 # Configure and run Darkstat
54 sed -i "s/START_DARKSTAT=.*/START_DARKSTAT=yes/g" /etc/darkstat/init.cfg
55 sed -i "s/INTERFACE=.*/INTERFACE=\"-i eth1\"/g" /etc/darkstat/init.cfg
56 /etc/init.d/darkstat start
58 # Download scripts for virtual sink
60 unzip -p -j /opt/vfw-scripts-$INSTALL_SCRIPT_VERSION.zip v_sink_init.sh > /opt/v_sink_init.sh
61 unzip -p -j /opt/vfw-scripts-$INSTALL_SCRIPT_VERSION.zip vsink.sh > /opt/vsink.sh
62 chmod +x v_sink_init.sh
65 # Run instantiation script
66 mv vsink.sh /etc/init.d
67 update-rc.d vsink.sh defaults