run.sh 876 Bytes
Newer Older
Rohan's avatar
Rohan committed
1
#!/bin/bash
Rohan's avatar
Rohan committed
2
3
4
5
6
7
8

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

base=$(dirname $0)

Rohan's avatar
Rohan committed
9
10
APP="$base/bin/vpp"
ARGS="-c $base/etc/startup_debug.conf"
Rohan's avatar
Rohan committed
11
12
13
14
15
16
17

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

while getopts ":r" opt; do
    case $opt in
	r)
Rohan's avatar
Rohan committed
18
19
	    APP="$base/bin/vpp"
	    ARGS="-c $base/etc/startup.conf"
Rohan's avatar
Rohan committed
20
21
22
23
24
25
26
27
	    ;;
	\?)
	    echo "Invalid option: -$OPTARG\n" >&2
	    echo "$USAGE" >&2
	    exit 1
	    ;;
    esac
done
Rohan's avatar
Rohan committed
28

Rohan's avatar
Rohan committed
29
30
31
shift $((OPTIND-1))

if test -z "$1"; then
Rohan's avatar
Rohan committed
32
    $APP $ARGS &
Rohan's avatar
Rohan committed
33
34
35
36
37
38
39
40
elif test "$1" = "debug"; then
    shift
    gdb -ex 'set print pretty on' -ex 'run' --args $APP $ARGS $@
else
    echo "$USAGE" >&2
    exit 1
fi

Rohan's avatar
Rohan committed
41
42
43
44
45
46
47
48
if [[ ${REGISTER_NRF} == "yes" ]];then
    sleep 5
    NRF_APP="$base/bin/nrf_client.py"
    NRF_ARGS=" --nrf_ip="$NRF_IP_ADDR" --nrf_port="$NRF_PORT" --http_version="$HTTP_VERSION
    python $NRF_APP $NRF_ARGS
fi