Refactor vCPE vG-MUX and vG image creation process
[demo.git] / vnfs / vCPE / scripts / v_gw_build.sh
1 #!/bin/bash
2
3
4 VPP_SOURCE_REPO_URL=$(cat /opt/config/vpp_source_repo_url.txt)
5 VPP_SOURCE_REPO_RELEASE_TAG=$(cat /opt/config/vpp_source_repo_release_tag.txt)
6 HC2VPP_SOURCE_REPO_URL=$(cat /opt/config/hc2vpp_source_repo_url.txt)
7 HC2VPP_SOURCE_REPO_RELEASE_TAG=$(cat /opt/config/hc2vpp_source_repo_release_tag.txt)
8 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
9
10
11 # Download required dependencies
12 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
13 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
14 apt-get --allow-unauthenticated update
15 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
16 sleep 1
17
18 # Install the tools required for download codes
19 apt-get --allow-unauthenticated install -y expect git make linux-image-extra-`uname -r`
20
21 #Install DHCP server
22 apt-get install -y isc-dhcp-server
23
24 #Download and build the VPP codes
25 cd /opt
26 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_RELEASE_TAG} vpp
27
28 cd vpp
29 yes y | make install-dep
30
31 cd build-root
32 ./bootstrap.sh
33 make V=0 PLATFORM=vpp TAG=vpp install-deb
34
35 # Install the VPP package
36 dpkg -i *.deb
37 systemctl stop vpp
38
39
40
41 # Download and install HC2VPP from source
42 cd /opt
43 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_RELEASE_TAG} hc2vpp
44
45 apt --allow-unauthenticated install -y python-ply-lex-3.5 python-ply-yacc-3.5 python-pycparser python-cffi
46 apt-get install -y maven
47 mkdir -p ~/.m2
48 cat > ~/.m2/settings.xml << EOF
49 <?xml version="1.0" encoding="UTF-8"?>
50 <!-- vi: set et smarttab sw=2 tabstop=2: -->
51 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
52   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
54
55   <profiles>
56     <profile>
57       <id>fd.io-release</id>
58       <repositories>
59         <repository>
60           <id>fd.io-mirror</id>
61           <name>fd.io-mirror</name>
62           <url>https://nexus.fd.io/content/groups/public/</url>
63           <releases>
64             <enabled>true</enabled>
65             <updatePolicy>never</updatePolicy>
66           </releases>
67           <snapshots>
68             <enabled>false</enabled>
69           </snapshots>
70         </repository>
71       </repositories>
72       <pluginRepositories>
73         <pluginRepository>
74           <id>fd.io-mirror</id>
75           <name>fd.io-mirror</name>
76           <url>https://nexus.fd.io/content/repositories/public/</url>
77           <releases>
78             <enabled>true</enabled>
79             <updatePolicy>never</updatePolicy>
80           </releases>
81           <snapshots>
82             <enabled>false</enabled>
83           </snapshots>
84         </pluginRepository>
85       </pluginRepositories>
86     </profile>
87
88     <profile>
89       <id>fd.io-snapshots</id>
90       <repositories>
91         <repository>
92           <id>fd.io-snapshot</id>
93           <name>fd.io-snapshot</name>
94           <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
95           <releases>
96             <enabled>false</enabled>
97           </releases>
98           <snapshots>
99             <enabled>true</enabled>
100           </snapshots>
101         </repository>
102       </repositories>
103       <pluginRepositories>
104         <pluginRepository>
105           <id>fd.io-snapshot</id>
106           <name>fd.io-snapshot</name>
107           <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
108           <releases>
109             <enabled>false</enabled>
110           </releases>
111           <snapshots>
112             <enabled>true</enabled>
113           </snapshots>
114         </pluginRepository>
115       </pluginRepositories>
116     </profile>
117     <profile>
118       <id>opendaylight-snapshots</id>
119       <repositories>
120         <repository>
121           <id>opendaylight-snapshot</id>
122           <name>opendaylight-snapshot</name>
123           <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
124           <releases>
125             <enabled>false</enabled>
126           </releases>
127           <snapshots>
128             <enabled>true</enabled>
129           </snapshots>
130         </repository>
131       </repositories>
132       <pluginRepositories>
133         <pluginRepository>
134           <id>opendaylight-shapshot</id>
135           <name>opendaylight-snapshot</name>
136           <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
137           <releases>
138             <enabled>false</enabled>
139           </releases>
140           <snapshots>
141             <enabled>true</enabled>
142           </snapshots>
143         </pluginRepository>
144       </pluginRepositories>
145     </profile>
146   </profiles>
147
148   <activeProfiles>
149     <activeProfile>fd.io-release</activeProfile>
150     <activeProfile>fd.io-snapshots</activeProfile>
151     <activeProfile>opendaylight-snapshots</activeProfile>
152   </activeProfiles>
153 </settings>
154 EOF
155
156 cd hc2vpp
157 mvn clean install
158 l_version=$(cat pom.xml | grep "<version>" | head -1)
159 l_version=$(echo "${l_version%<*}")
160 l_version=$(echo "${l_version#*>}")
161 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
162 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
163
164 # Disable automatic upgrades
165 if [[ $CLOUD_ENV != "rackspace" ]]
166 then
167     echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
168     sed -i 's/\(APT::Periodic::Unattended-Upgrade\) "1"/\1 "0"/' /etc/apt/apt.conf.d/20auto-upgrades
169 fi
170