summaryrefslogtreecommitdiffstats
path: root/build-root/vagrant
diff options
context:
space:
mode:
authorEd Warnicke <eaw@cisco.com>2016-04-12 17:34:48 -0500
committerDamjan Marion <damarion@cisco.com>2016-04-25 17:27:09 +0000
commitd6a0fc5ea696763c3cba67dc47d8e7943ae7649b (patch)
tree82a091f6f1386af61709c6c11c82de5578878ab5 /build-root/vagrant
parent108c7313854953ee3b66069b902f9fabb097ed25 (diff)
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>
Diffstat (limited to 'build-root/vagrant')
-rw-r--r--build-root/vagrant/README.moved5
-rw-r--r--build-root/vagrant/Vagrantfile9
-rw-r--r--build-root/vagrant/bootstrap.ubuntu1404.sh39
-rw-r--r--build-root/vagrant/bootstrap.ubuntu1604.sh39
-rwxr-xr-xbuild-root/vagrant/build.sh54
-rwxr-xr-x[-rw-r--r--]build-root/vagrant/clearinterfaces.sh (renamed from build-root/vagrant/bootstrap.centos7.sh)30
-rwxr-xr-xbuild-root/vagrant/run.sh22
-rwxr-xr-xbuild-root/vagrant/update.sh45
8 files changed, 132 insertions, 111 deletions
diff --git a/build-root/vagrant/README.moved b/build-root/vagrant/README.moved
deleted file mode 100644
index 2bbf6564512..00000000000
--- a/build-root/vagrant/README.moved
+++ /dev/null
@@ -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.
diff --git a/build-root/vagrant/Vagrantfile b/build-root/vagrant/Vagrantfile
index 6e42bf272ca..5e6fe755800 100644
--- a/build-root/vagrant/Vagrantfile
+++ b/build-root/vagrant/Vagrantfile
@@ -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
diff --git a/build-root/vagrant/bootstrap.ubuntu1404.sh b/build-root/vagrant/bootstrap.ubuntu1404.sh
deleted file mode 100644
index daa68bc42c8..00000000000
--- a/build-root/vagrant/bootstrap.ubuntu1404.sh
+++ /dev/null
@@ -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
diff --git a/build-root/vagrant/bootstrap.ubuntu1604.sh b/build-root/vagrant/bootstrap.ubuntu1604.sh
deleted file mode 100644
index 2e607f1e847..00000000000
--- a/build-root/vagrant/bootstrap.ubuntu1604.sh
+++ /dev/null
@@ -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
diff --git a/build-root/vagrant/build.sh b/build-root/vagrant/build.sh
new file mode 100755
index 00000000000..b608b853397
--- /dev/null
+++ b/build-root/vagrant/build.sh
@@ -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
+
diff --git a/build-root/vagrant/bootstrap.centos7.sh b/build-root/vagrant/clearinterfaces.sh
index 36af564a14f..78f6705ca32 100644..100755
--- a/build-root/vagrant/bootstrap.centos7.sh
+++ b/build-root/vagrant/clearinterfaces.sh
@@ -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
diff --git a/build-root/vagrant/run.sh b/build-root/vagrant/run.sh
new file mode 100755
index 00000000000..7342f38881e
--- /dev/null
+++ b/build-root/vagrant/run.sh
@@ -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
diff --git a/build-root/vagrant/update.sh b/build-root/vagrant/update.sh
new file mode 100755
index 00000000000..77bf49a7792
--- /dev/null
+++ b/build-root/vagrant/update.sh
@@ -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 \ No newline at end of file