2 set -o xtrace # print commands during script execution
3 set -o errexit # exit on command errors
5 VPP_SOURCE_REPO_URL=$(cat /opt/config/vpp_source_repo_url.txt)
6 VPP_SOURCE_REPO_RELEASE_TAG=$(cat /opt/config/vpp_source_repo_release_tag.txt)
7 VPP_PATCH_URL=$(cat /opt/config/vpp_patch_url.txt)
8 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
9 ERROR_MESSAGE='Execution of vBRG script failed.'
11 # Convert Network CIDR to Netmask
13 # Number of args to shift, 255..255, first non-255 byte, zeroes
14 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
15 [ $1 -gt 1 ] && shift $1 || shift
16 echo ${1-0}.${2-0}.${3-0}.${4-0}
20 # Enable IPV4 forwarding through kernel
21 sed -i 's/^.*\(net.ipv4.ip_forward\).*/\1=1/g' /etc/sysctl.conf
22 sysctl -p /etc/sysctl.conf
24 # Download required dependencies
25 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
26 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
28 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
31 # Install the tools required for download codes
32 apt-get install -y expect git patch make autoconf libtool linux-image-extra-`uname -r`
34 # Download and build the VPP codes
36 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_RELEASE_TAG} vpp
37 wget -O Vpp-Integrate-FreeRADIUS-Client-for-vBNG.patch ${VPP_PATCH_URL}
39 # The patch will place a "dummy" version of dhcp.api.h so the build will succeed
40 mkdir -p build-root/build-vpp-native/vpp/vnet/dhcp/
41 patch -p1 < ../Vpp-Integrate-FreeRADIUS-Client-for-vBNG.patch
42 UNATTENDED='y' make install-dep
44 # Check VPP build status
47 echo $ERROR_MESSAGE 'Reason: VPP build failed' > /opt/script_status.txt
51 # Install the FreeRADIUS client since we need the lib
53 git clone https://github.com/FreeRADIUS/freeradius-client.git
57 cd /usr/local/lib && ln -s -f libfreeradius-client.so.2.0.0 libfreeradiusclient.so
60 cd /opt/vpp/build-root
62 make V=0 PLATFORM=vpp TAG=vpp install-deb
64 # Check vpp/build-root status
67 echo $ERROR_MESSAGE 'Reason: vpp/build-root build failed' > /opt/script_status.txt
71 # Install additional dependencies for vpp
72 apt-get install -y python-cffi python-ply python-pycparser
74 # Install the VPP package
75 cd /opt/vpp/build-root
78 # Check VPP package installation status
81 echo $ERROR_MESSAGE 'Reason: VPP package installation failed' > /opt/script_status.txt
87 # Disable automatic upgrades
88 if [[ $CLOUD_ENV != "rackspace" ]]
90 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
91 sed -i 's/\(APT::Periodic::Unattended-Upgrade\) "1"/\1 "0"/' /etc/apt/apt.conf.d/20auto-upgrades
94 # Indicate script has finished executing
95 echo 'Execution of vBNG build script completed' > /opt/script_status.txt