comparison scripts/run_project.sh @ 332:ccd084cf22ac prerelease

run_project takes parameter for project name (defaults to scriptUploadedProject)
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 04 Jun 2016 16:23:40 +0100
parents d41631e0fe0e
children 8e0dee85b73a
comparison
equal deleted inserted replaced
331:cfdf0003e6e8 332:ccd084cf22ac
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # This script runs an already-compiled BeagleRT project on the 3 # This script runs an already-compiled BeagleRT project on the
4 # BeagleBone Black. 4 # BeagleBone Black.
5 5
6 BBB_ADDRESS="root@192.168.7.2" 6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
7 BBB_PATH="~/BeagleRT" 7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/"
8 COMMAND_ARGS= 8 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="BeagleRT"
9 RUN_IN_FOREGROUND=0 9 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
10 RUN_WITHOUT_SCREEN=0 10 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
11 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
12 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
13 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
14 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
11 15
12 function usage 16 function usage
13 { 17 {
14 THIS_SCRIPT=`basename "$0"` 18 THIS_SCRIPT=`basename "$0"`
15 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]" 19 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]"
16 20
17 echo " 21 echo "
18 This script runs a previously compiled BeagleRT project on the 22 This script runs a previously compiled BeagleRT project on the
19 BeagleBone Black. The -b option changes the default path, which 23 BeagleBone Black. The -b option changes the default path, which
20 is otherwise $BBB_PATH. The -c option passes command-line arguments 24 is otherwise $BBB_BELA_HOME. The -c option passes command-line arguments
21 to the BeagleRT program; enclose the argument string in quotes. 25 to the BeagleRT program; enclose the argument string in quotes.
22 26
23 The -f argument runs the project in the foreground of the current terminal, 27 The -f argument runs the project in the foreground of the current terminal,
24 within a screen session that can be detached later. The -F argument runs 28 within a screen session that can be detached later. The -F argument runs
25 the project in the foreground of the current terminal, without screen, so 29 the project in the foreground of the current terminal, without screen, so
28 32
29 OPTIND=1 33 OPTIND=1
30 34
31 while getopts "b:c:fFh" opt; do 35 while getopts "b:c:fFh" opt; do
32 case $opt in 36 case $opt in
33 b) BBB_PATH=$OPTARG 37 b) BBB_BELA_HOME=$OPTARG
34 ;; 38 ;;
35 c) COMMAND_ARGS=$OPTARG 39 c) COMMAND_ARGS=$OPTARG
36 ;; 40 ;;
37 f) RUN_IN_FOREGROUND=1 41 f) RUN_IN_FOREGROUND=1
38 ;; 42 ;;
39 F) RUN_WITHOUT_SCREEN=1 43 F) RUN_WITHOUT_SCREEN=1
40 ;; 44 ;;
41 h|\?) usage 45 h|\?) usage
42 exit 1 46 exit 1
43 esac 47 esac
44 done 48 done
45 49
50 if [ -z "$1" ]
51 then
52 BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
53 else
54 BBB_PROJECT_NAME=$1
55 fi
56
46 shift $((OPTIND-1)) 57 shift $((OPTIND-1))
47 58
48 echo "Running BeagleRT..." 59 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'"
60 echo "Running $BBB_PROJECT_NAME..."
49 if [ $RUN_WITHOUT_SCREEN -ne 0 ] 61 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
50 then 62 then
51 ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; $BBB_PATH/BeagleRT $COMMAND_ARGS" 63 ssh -t $BBB_ADDRESS "$MAKE_COMMAND run"
52 elif [ $RUN_IN_FOREGROUND -eq 0 ] 64 elif [ $RUN_IN_FOREGROUND -eq 0 ]
53 then 65 then
54 ssh $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" 66 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreenfg"
55 else 67 else
56 ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" 68 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreen"
57 fi 69 fi