install.sh revision 84e35ad1
1#!/usr/bin/env bash
2
3# Copyright (c) 2016 Cisco and/or its affiliates.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at:
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16VPP_VERSION="17.01-rc0~287-g7e4edc8~b1622"
17
18sysctl -w vm.nr_hugepages=1024
19HUGEPAGES=`sysctl -n  vm.nr_hugepages`
20if [ $HUGEPAGES != 1024 ]; then
21    echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES.  Cannot finish."
22    exit
23fi
24
25echo "deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
26apt-get -qq update
27apt-get -qq install -y --force-yes vpp=$VPP_VERSION vpp-lib=$VPP_VERSION vpp-dpdk-dkms=$VPP_VERSION bridge-utils lxc
28service vpp start
29
30#Configure LXC network to create an inteface for Linux bridge and a unconsumed second inteface
31echo -e "lxc.network.name=veth0\nlxc.network.type = veth\nlxc.network.name = veth_link1"  | sudo tee -a /etc/lxc/default.conf
32
33lxc-checkconfig
34
35containers=( cone ctwo )
36
37for i in "${containers[@]}"
38do
39    sudo lxc-create -t download -n $i -- --dist ubuntu --release trusty --arch amd64
40done
41
42for i in "${containers[@]}"
43do
44    sudo lxc-start -n $i -d
45done
46
47function lxc_exec() {
48
49    cntr="$1"
50    rCMD="$2"
51
52    CMD="sudo lxc-attach -n $cntr  -- $rCMD"
53
54    echo "$CMD"
55    eval "${CMD}"
56}
57
58for i in "${containers[@]}"
59do
60    lxc_exec $i "resolvconf -d eth0"
61    lxc_exec $i "dhclient"
62
63    lxc_exec $i "sh -c 'echo \"deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./\" >> /etc/apt/sources.list.d/99fd.io.list'"
64    lxc_exec $i "apt-get -qq install -y wget"
65    lxc_exec $i "apt-get -qq update"
66    lxc_exec $i "apt-get -qq install -y --force-yes vpp"
67    lxc_exec $i "sh -c 'echo  \"\\ndpdk {\\n   no-pci\\n}\" >> /etc/vpp/startup.conf'"
68    lxc_exec $i "service vpp start"
69done
70
71for i in "${containers[@]}"
72do
73    sudo lxc-stop -n $i
74done
75
76#UI dependencies
77curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
78sudo apt-get install -y nodejs
79
80#setup the npm proxy config correctly
81if [[ -v http_proxy ]]; then
82        sudo npm config set proxy $http_proxy
83fi
84
85if [[ -v https_proxy ]]; then
86	npm_https_proxy=$(sed 's/https/http/' <<< $https_proxy)
87        sudo npm config set https-proxy $npm_https_proxy
88fi
89
90#install nodeJS backend
91sudo npm install /vagrant/ui/backend/
92sudo mv node_modules/vppsb/node_modules/ /vagrant/ui/backend/
93sudo npm install -g forever
94sudo forever start /vagrant/ui/backend/server.js
95