Make vagrant work behind a proxy

Without this change, I cannot get the in-tree VPP Vagrant to work behind
a proxy. This commit fixes that by ensuring when we run sudo we're passing
environment variables, amongst some other cleanups.

Change-Id: Ica98a1238d40e6e6ccf80c472f52559c95af52f0
Signed-off-by: Kyle Mestery <mestery@mestery.com>
diff --git a/extras/vagrant/Vagrantfile b/extras/vagrant/Vagrantfile
index badaa97..a97a3dc 100644
--- a/extras/vagrant/Vagrantfile
+++ b/extras/vagrant/Vagrantfile
@@ -12,6 +12,8 @@
   elsif distro == 'opensuse'
     config.vm.box = "opensuse/openSUSE-42.3-x86_64"
     config.vm.box_version = "1.0.4.20170726"
+  elsif distro == 'ubuntu1804'
+    config.vm.box = "bento/ubuntu-18.04"
   else
     config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
   end
diff --git a/extras/vagrant/build.sh b/extras/vagrant/build.sh
index 86ed4cd..3a10e70 100755
--- a/extras/vagrant/build.sh
+++ b/extras/vagrant/build.sh
@@ -47,13 +47,13 @@
 if [ $OS_ID == "centos" ]; then
     echo rpm -V apr-devel
     rpm -V apr-devel
-    if [ $? != 0 ]; then sudo yum reinstall -y apr-devel;fi
+    if [ $? != 0 ]; then sudo -E yum reinstall -y apr-devel;fi
     echo rpm -V ganglia-devel
     rpm -V ganglia-devel
-    if [ $? != 0 ]; then sudo yum reinstall -y ganglia-devel;fi
+    if [ $? != 0 ]; then sudo -E yum reinstall -y ganglia-devel;fi
     echo rpm -V libconfuse-devel
     rpm -V libconfuse-devel
-    if [ $? != 0 ]; then sudo yum reinstall -y libconfuse-devel;fi
+    if [ $? != 0 ]; then sudo -E yum reinstall -y libconfuse-devel;fi
 fi
 
 # Build and install packaging
diff --git a/extras/vagrant/clearinterfaces.sh b/extras/vagrant/clearinterfaces.sh
index 78f6705..31a6309 100755
--- a/extras/vagrant/clearinterfaces.sh
+++ b/extras/vagrant/clearinterfaces.sh
@@ -12,6 +12,6 @@
 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
+        sudo -E ifconfig $intf down
     fi
 done
diff --git a/extras/vagrant/env.sh b/extras/vagrant/env.sh
index bd329ea..441a4c1 100644
--- a/extras/vagrant/env.sh
+++ b/extras/vagrant/env.sh
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 
-export VPP_VAGRANT_DISTRO="ubuntu1604"
+export VPP_VAGRANT_DISTRO="ubuntu1804"
 export VPP_VAGRANT_NICS=2
 export VPP_VAGRANT_VMCPU=4
 export VPP_VAGRANT_VMRAM=4096
+export VPP_VAGRANT_POST_BUILD=install
diff --git a/extras/vagrant/install.sh b/extras/vagrant/install.sh
old mode 100644
new mode 100755
index a53faa4..cfe5fe5
--- a/extras/vagrant/install.sh
+++ b/extras/vagrant/install.sh
@@ -12,7 +12,7 @@
 if [ -f /etc/lsb-release ];then
     . /etc/lsb-release
 elif [ -f /etc/redhat-release ];then
-    sudo yum install -y redhat-lsb
+    sudo -E yum install -y redhat-lsb
     DISTRIB_ID=`lsb_release -si`
     DISTRIB_RELEASE=`lsb_release -sr`
     DISTRIB_CODENAME=`lsb_release -sc`
@@ -24,7 +24,7 @@
 echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
 
 if [ $DISTRIB_ID == "Ubuntu" ]; then
-    (cd ${VPP_DIR}/build-root/;sudo dpkg -i *.deb)
+    (cd ${VPP_DIR}/build-root/;sudo -E dpkg -i *.deb)
 elif [ $DISTRIB_ID == "CentOS" ]; then
-    (cd ${VPP_DIR}/build-root/;sudo rpm -Uvh *.rpm)
-fi
\ No newline at end of file
+    (cd ${VPP_DIR}/build-root/;sudo -E rpm -Uvh *.rpm)
+fi
diff --git a/extras/vagrant/run.sh b/extras/vagrant/run.sh
index 3c779fa..61c9261 100755
--- a/extras/vagrant/run.sh
+++ b/extras/vagrant/run.sh
@@ -12,11 +12,12 @@
 
 if [ "$OS_ID" == "centos" ] || [ "$OS_ID" == "opensuse" ]; then
     # Install uio-pci-generic
-    modprobe uio_pci_generic
+    sudo -E modprobe uio_pci_generic
 fi
+
 echo "Starting VPP..."
-if [ "$OS_ID" == "ubuntu" ] && [ $OS_CODENAME = "trusty" ] ; then
-    start vpp
+if [ "$OS_ID" == "ubuntu" ] && [ "$OS_CODENAME" == "trusty" ] ; then
+    sudo -E start vpp
 else
-    service vpp start
+    sudo -E service vpp start
 fi