install.sh revision 764d4be7
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
16sysctl -w vm.nr_hugepages=1024
17HUGEPAGES=`sysctl -n  vm.nr_hugepages`
18if [ $HUGEPAGES != 1024 ]; then
19    echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES.  Cannot finish."
20    exit
21fi
22
23echo "deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
24apt-get -qq update
25apt-get -qq install -y --force-yes vpp vpp-dpdk-dkms bridge-utils lxc
26service vpp start
27
28#Configure LXC network to create an inteface for Linux bridge and a unconsumed second inteface
29echo -e "lxc.network.name=veth0\nlxc.network.type = veth\nlxc.network.name = veth_link1"  | sudo tee -a /etc/lxc/default.conf
30
31lxc-checkconfig
32
33containers=( cone ctwo )
34
35for i in "${containers[@]}"
36do
37    sudo lxc-create -t download -n $i -- --dist ubuntu --release trusty --arch amd64
38done
39
40for i in "${containers[@]}"
41do
42    sudo lxc-start -n $i -d
43done
44
45function lxc_exec() {
46
47    cntr="$1"
48    rCMD="$2"
49
50    CMD="sudo lxc-attach -n $cntr  -- $rCMD"
51
52    echo "$CMD"
53    eval "${CMD}"
54}
55
56for i in "${containers[@]}"
57do
58    lxc_exec $i "resolvconf -d eth0"
59    lxc_exec $i "dhclient"
60
61    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'"
62    lxc_exec $i "apt-get -qq install -y wget"
63    lxc_exec $i "apt-get -qq update"
64    lxc_exec $i "apt-get -qq install -y --force-yes vpp"
65    lxc_exec $i "sh -c 'echo  \"\\ndpdk {\\n   no-pci\\n}\" >> /etc/vpp/startup.conf'"
66    lxc_exec $i "service vpp start"
67done
68
69for i in "${containers[@]}"
70do
71    sudo lxc-stop -n $i
72done
73