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 MR_IP_ADDR=$(cat /opt/config/mr_ip_addr.txt)
10 # Convert Network CIDR to Netmask
12 # Number of args to shift, 255..255, first non-255 byte, zeroes
13 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
14 [ $1 -gt 1 ] && shift $1 || shift
15 echo ${1-0}.${2-0}.${3-0}.${4-0}
18 # OpenStack network configuration
19 if [[ $CLOUD_ENV == "openstack" ]]
21 echo 127.0.0.1 $(hostname) >> /etc/hosts
23 # Allow remote login as root
24 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
25 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
27 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
29 IP=$(cat /opt/config/cpe_signal_ipaddr.txt)
30 BITS=$(cat /opt/config/cpe_signal_net_cidr.txt | cut -d"/" -f2)
31 NETMASK=$(cdr2mask $BITS)
32 echo "auto eth1" >> /etc/network/interfaces
33 echo "iface eth1 inet static" >> /etc/network/interfaces
34 echo " address $IP" >> /etc/network/interfaces
35 echo " netmask $NETMASK" >> /etc/network/interfaces
36 echo " mtu $MTU" >> /etc/network/interfaces
38 IP=$(cat /opt/config/oam_ipaddr.txt)
39 BITS=$(cat /opt/config/oam_cidr.txt | cut -d"/" -f2)
40 NETMASK=$(cdr2mask $BITS)
41 echo "auto eth2" >> /etc/network/interfaces
42 echo "iface eth2 inet static" >> /etc/network/interfaces
43 echo " address $IP" >> /etc/network/interfaces
44 echo " netmask $NETMASK" >> /etc/network/interfaces
45 echo " mtu $MTU" >> /etc/network/interfaces
51 # Download required dependencies
52 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
53 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
55 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates kea-dhcp4-server g++ libcurl4-gnutls-dev libboost-dev kea-dev
58 # Download the kea hook
60 wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/vcpe/kea-sdnc-notify-mod/$DEMO_ARTIFACTS_VERSION/kea-sdnc-notify-mod-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
61 tar -zxvf kea-sdnc-notify-mod-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
62 mv kea-sdnc-notify-mod-$DEMO_ARTIFACTS_VERSION VDHCP
65 # build.sh takes a minute or two to run
67 mv build/kea-sdnc-notify.so /usr/local/lib
69 # Download DHCP config files
71 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/kea-dhcp4.conf
72 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/kea-sdnc-notify.conf
73 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_dhcp_init.sh
74 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_dhcp.sh
75 chmod +x v_dhcp_init.sh
77 mv v_dhcp.sh /etc/init.d
78 update-rc.d v_dhcp.sh defaults
81 cp kea-dhcp4.conf /etc/kea-dhcp4-server.conf
82 mv kea-dhcp4.conf /etc/kea/kea-dhcp4.conf
83 sed -i "s/DMAAP_IPADDR/"$MR_IP_ADDR"/g" kea-sdnc-notify.conf
84 mv kea-sdnc-notify.conf /etc/kea/kea-sdnc-notify.conf
87 ######################################################################################
88 ### KEA install automatically puts kea-dhcp4-server in /etc/init.d and does update.rc
89 # rc0.d/K01kea-dhcp4-server
90 #rc1.d/K01kea-dhcp4-server
91 #rc2.d/S03kea-dhcp4-server
92 #rc3.d/S03kea-dhcp4-server
93 #rc4.d/S03kea-dhcp4-server
94 #rc5.d/S03kea-dhcp4-server
95 #rc6.d/K01kea-dhcp4-server
96 ######################################################################################
98 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
99 if [[ $CLOUD_ENV != "rackspace" ]]
101 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
102 grub-mkconfig -o /boot/grub/grub.cfg
103 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
104 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
105 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
106 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic