Break boostrap.sh into pieces

In order to make it easier for folks who have existing
Centos or Ubuntu boxes to utilize the same
'Getting started' scripting that is used in Vagrant,
as well as enable us to use that scripting in CI,
broke up bootstrap.sh into

update.sh - Things like apt-get update
build.sh - Install any dependencies and build vpp
clearinterfaces.sh - Clean off any non-default gateway
                   interfaces.  Used by vagrant.
run.sh - Start vpp as a service on the box.

A user (or CI) just wanting to get going and build
on an existing Ubuntu or Centos image (ie, not via
vagrant) can simply run

build.sh

Change-Id: I8f19342f163cad07c6c05def943a5fb8e394b879
Signed-off-by: Ed Warnicke <eaw@cisco.com>
This commit is contained in:
Ed Warnicke
2016-04-12 17:34:48 -05:00
committed by Damjan Marion
parent 108c731385
commit d6a0fc5ea6
8 changed files with 132 additions and 111 deletions

View File

@ -1,5 +0,0 @@
The location of the vpp code has moved from
~/git/vpp
To
/vpp
/vpp is a mount of the source code from outside the Vagrant, and should make it much easier to interact with the system.

View File

@ -7,12 +7,15 @@ Vagrant.configure(2) do |config|
distro = ENV['VPP_VAGRANT_DISTRO']
if distro == 'centos7'
config.vm.box = "puppetlabs/centos-7.2-64-nocm"
config.vm.provision 'shell', path: 'bootstrap.centos7.sh'
else
config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
config.vm.provision 'shell', path: 'bootstrap.ubuntu1404.sh'
end
config.vm.provision :shell, :path => "update.sh"
config.vm.provision :shell, :path => "build.sh", :args => "/vpp vagrant"
config.vm.provision :shell, :path => "clearinterfaces.sh"
config.vm.provision :shell, :path => "run.sh"
# Add .gnupg dir in so folks can sign patches
# Note, as gnupg puts socket files in that dir, we have
# to be cautious and make sure we are dealing with a plain file
@ -39,7 +42,7 @@ Vagrant.configure(2) do |config|
end
# Define some physical ports for your VMs to be used by DPDK
nics = 0
nics = 2
if ENV.key?('VPP_VAGRANT_NICS')
nics = ENV['VPP_VAGRANT_NICS'].to_i(10)
end

View File

@ -1,39 +0,0 @@
# Fix grub-pc on Virtualbox with Ubuntu
export DEBIAN_FRONTEND=noninteractive
# Standard update + upgrade dance
apt-get update
apt-get upgrade -y
# Fix the silly notion that /bin/sh should point to dash by pointing it to bash
sudo update-alternatives --install /bin/sh sh /bin/bash 100
cd /vpp
sudo -H -u vagrant make install-dep
# Install useful but non-mandatory tools
apt-get install -y emacs git-review gdb gdbserver
sudo -H -u vagrant make bootstrap
sudo -H -u vagrant make pkg-deb
(cd build-root/;dpkg -i *.deb)
# Capture all the interface IPs, in case we need them later
ifconfig -a > ~vagrant/ifconfiga
chown vagrant:vagrant ~vagrant/ifconfiga
# Disable all ethernet interfaces other than the default route
# interface so VPP will use those interfaces. The VPP auto-blacklist
# algorithm prevents the use of any physical interface contained in the
# routing table (i.e. "route --inet --inet6") preventing the theft of
# the management ethernet interface by VPP from the kernel.
for intf in $(ls /sys/class/net) ; do
if [ -d /sys/class/net/$intf/device ] &&
[ "$(route --inet --inet6 | grep default | grep $intf)" == "" ] ; then
ifconfig $intf down
fi
done
start vpp
cat /vagrant/README

View File

@ -1,39 +0,0 @@
# Fix grub-pc on Virtualbox with Ubuntu
export DEBIAN_FRONTEND=noninteractive
# Standard update + upgrade dance
apt-get update
apt-get upgrade -y
# Fix the silly notion that /bin/sh should point to dash by pointing it to bash
sudo update-alternatives --install /bin/sh sh /bin/bash 100
cd /vpp
sudo -H -u vagrant make install-dep
# Install useful but non-mandatory tools
apt-get install -y emacs git-review gdb gdbserver
sudo -H -u vagrant make bootstrap
sudo -H -u vagrant make pkg-deb
(cd build-root/;dpkg -i *.deb)
# Capture all the interface IPs, in case we need them later
ifconfig -a > ~vagrant/ifconfiga
chown vagrant:vagrant ~vagrant/ifconfiga
# Disable all ethernet interfaces other than the default route
# interface so VPP will use those interfaces. The VPP auto-blacklist
# algorithm prevents the use of any physical interface contained in the
# routing table (i.e. "route --inet --inet6") preventing the theft of
# the management ethernet interface by VPP from the kernel.
for intf in $(ls /sys/class/net) ; do
if [ -d /sys/class/net/$intf/device ] &&
[ "$(route --inet --inet6 | grep default | grep $intf)" == "" ] ; then
ifconfig $intf down
fi
done
systemctl start vpp
cat /vagrant/README

54
build-root/vagrant/build.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
# Get Command Line arguements if present
VPP_DIR=$1
if [ "x$1" != "x" ]; then
VPP_DIR=$1
else
VPP_DIR=`dirname $0`/../../
fi
if [ "x$2" != "x" ]; then
SUDOCMD="sudo -H -u $2"
fi
echo 0:$0
echo 1:$1
echo 2:$2
echo VPP_DIR: $VPP_DIR
echo SUDOCMD: $SUDOCMD
# Figure out what system we are running on
if [ -f /etc/lsb-release ];then
. /etc/lsb-release
elif [ -f /etc/redhat-release ];then
sudo yum install -y redhat-lsb
DISTRIB_ID=`lsb_release -si`
DISTRIB_RELEASE=`lsb_release -sr`
DISTRIB_CODENAME=`lsb_release -sc`
DISTRIB_DESCRIPTION=`lsb_release -sd`
fi
echo DISTRIB_ID: $DISTRIB_ID
echo DISTRIB_RELEASE: $DISTRIB_RELEASE
echo DISTRIB_CODENAME: $DISTRIB_CODENAME
echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
# Install dependencies
cd $VPP_DIR
make install-dep
# Really really clean things up so we can be sure
# that the build works even when switching distros
make wipe
(cd build-root/;make distclean)
rm -f build-root/.bootstrap.ok
# Build and install packaging
$SUDOCMD make bootstrap
if [ $DISTRIB_ID == "Ubuntu" ]; then
$SUDOCMD make pkg-deb
(cd build-root/;sudo dpkg -i *.deb)
elif [ $DISTRIB_ID == "CentOS" ]; then
$SUDOCMD make pkg-rpm
(cd build-root/;sudo rpm -Uvh *.rpm)
fi

View File

@ -1,19 +1,8 @@
#!/bin/bash
# Standard update + upgrade dance
yum check-update
yum update -y
# Install dependencies
cd /vpp
make install-dep
# Build rpms
sudo -H -u vagrant make bootstrap
sudo -H -u vagrant make pkg-rpm
# Install rpms
(cd build-root/;sudo rpm -Uvh *.rpm)
# Capture all the interface IPs, in case we need them later
ip -o addr show > ~vagrant/ifconfiga
chown vagrant:vagrant ~vagrant/ifconfiga
# Disable all ethernet interfaces other than the default route
# interface so VPP will use those interfaces. The VPP auto-blacklist
@ -21,17 +10,8 @@ sudo -H -u vagrant make pkg-rpm
# routing table (i.e. "route --inet --inet6") preventing the theft of
# the management ethernet interface by VPP from the kernel.
for intf in $(ls /sys/class/net) ; do
if [ -d /sys/class/net/$intf/device ] &&
if [ -d /sys/class/net/$intf/device ] &&
[ "$(route --inet --inet6 | grep default | grep $intf)" == "" ] ; then
ifconfig $intf down
fi
done
# Install uio-pci-generic
modprobe uio_pci_generic
# Start vpp
service vpp start
# cat README
cat /vagrant/README

22
build-root/vagrant/run.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Figure out what system we are running on
if [ -f /etc/lsb-release ];then
. /etc/lsb-release
elif [ -f /etc/redhat-release ];then
yum install -y redhat-lsb
DISTRIB_ID=`lsb_release -si`
DISTRIB_RELEASE=`lsb_release -sr`
DISTRIB_CODENAME=`lsb_release -sc`
DISTRIB_DESCRIPTION=`lsb_release -sd`
fi
if [ $DISTRIB_ID == "Ubuntu" ]; then
start vpp
elif [ $DISTRIB_ID == "CentOS" ]; then
# Install uio-pci-generic
modprobe uio_pci_generic
# Start vpp
service vpp start
fi

45
build-root/vagrant/update.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# Make sure that we get the hugepages we need on provision boot
# Note: The package install should take care of this at the end
# But sometimes after all the work of provisioning, we can't
# get the requested number of hugepages without rebooting.
# So do it here just in case
sysctl -w vm.nr_hugepages=1024
HUGEPAGES=`sysctl -n vm.nr_hugepages`
if [ $HUGEPAGES != 1024 ]; then
echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES. Cannot finish."
exit
fi
# Figure out what system we are running on
if [ -f /etc/lsb-release ];then
. /etc/lsb-release
elif [ -f /etc/redhat-release ];then
yum install -y redhat-lsb
DISTRIB_ID=`lsb_release -si`
DISTRIB_RELEASE=`lsb_release -sr`
DISTRIB_CODENAME=`lsb_release -sc`
DISTRIB_DESCRIPTION=`lsb_release -sd`
fi
# Do initial setup for the system
if [ $DISTRIB_ID == "Ubuntu" ]; then
# Fix grub-pc on Virtualbox with Ubuntu
export DEBIAN_FRONTEND=noninteractive
# Standard update + upgrade dance
apt-get update
apt-get upgrade -y
# Fix the silly notion that /bin/sh should point to dash by pointing it to bash
update-alternatives --install /bin/sh sh /bin/bash 100
# Install useful but non-mandatory tools
apt-get install -y emacs git-review gdb gdbserver
elif [ $DISTRIB_ID == "CentOS" ]; then
# Standard update + upgrade dance
yum check-update
yum update -y
fi