Minor additions to setup script.
[one.git] / tutorial / setup_lisp_topo.sh
index b38ee5d..872ccd8 100755 (executable)
@@ -1,5 +1,19 @@
+#!/usr/bin/env bash
+
+if [ $USER != "root" ] ; then
+    echo "Restarting script with sudo..."
+    sudo $0 ${*}
+    exit
+fi
+
+
+SRC=${1:-/vpp}
+[ $# -eq 0 ] && { echo "(using default vpp src $SRC. This can be passed as parameter to script)"; }
+
 # path to vpp executable and configurations folder
-VPP_LITE_BIN=/vpp/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
+[ -f $SRC/build-root/install-vpp_lite_debug-native/vpp/bin/vpp ] || { echo "VPP lite not found, build it by 'cd $SRC; PLATFORM=vpp_lite make build'"; exit 1; }
+
+VPP_LITE_BIN=$SRC/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
 VPP_LITE_CONF=/etc/vpp/lite/
 
 # make sure there are no vpp instances running
@@ -75,14 +89,14 @@ ifconfig odl 6.0.3.100/24
 ethtool --offload  odl rx off tx off
 
 # start vpp1 and vpp2 in separate chroot
-sudo $VPP_LITE_BIN                              \
-  unix { log /tmp/vpp1.log cli-listen           \
-         localhost:5002 full-coredump           \
-         exec $VPP_LITE_CONF/vpp1.conf }        \
-         api-trace { on } chroot {prefix xtr1}
-
-sudo $VPP_LITE_BIN                              \
-  unix { log /tmp/vpp2.log cli-listen           \
-         localhost:5003 full-coredump           \
-         exec $VPP_LITE_CONF/vpp2.conf}         \
-         api-trace { on } chroot {prefix xtr2}
+sudo $VPP_LITE_BIN                                  \
+  unix { log /tmp/vpp1.log cli-listen               \
+         localhost:5002 full-coredump               \
+         exec $VPP_LITE_CONF/vpp1.conf }            \
+         api-trace { on } api-segment {prefix xtr1}
+
+sudo $VPP_LITE_BIN                                  \
+  unix { log /tmp/vpp2.log cli-listen               \
+         localhost:5003 full-coredump               \
+         exec $VPP_LITE_CONF/vpp2.conf}             \
+         api-trace { on } api-segment {prefix xtr2}