run.sh 675 Bytes
Newer Older
Rohan's avatar
Rohan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh -x

if [ $(id -u) -ne 0 ]; then
    exec sudo -E "$0" "$@"
fi

base=$(dirname $0)

APP="/openair-upf/bin/vpp"
ARGS="-c /openair-upf/bin/startup_debug.conf"

USAGE="Usage: run.sh [-r] [ debug ]
       debug:	executes vpp under gdb"

while getopts ":r" opt; do
    case $opt in
	r)
	    APP="/openair-upf/bin/vpp"
	    ARGS="-c $base/startup.conf"
	    ;;
	\?)
	    echo "Invalid option: -$OPTARG\n" >&2
	    echo "$USAGE" >&2
	    exit 1
	    ;;
    esac
done
shift $((OPTIND-1))

if test -z "$1"; then
    $APP $ARGS
elif test "$1" = "debug"; then
    shift
    gdb -ex 'set print pretty on' -ex 'run' --args $APP $ARGS $@
else
    echo "$USAGE" >&2
    exit 1
fi