comparison scripts/run_project.sh @ 62:a11e23f4e6af newapi

Added script options for running in a loop at startup (needs further support for stopping) and running the project in the foreground
author andrewm
date Wed, 15 Jul 2015 19:40:15 +0100
parents afc593f7469e
children 3ada83df91a5
comparison
equal deleted inserted replaced
61:afc593f7469e 62:a11e23f4e6af
4 # BeagleBone Black. 4 # BeagleBone Black.
5 5
6 BBB_ADDRESS="root@192.168.7.2" 6 BBB_ADDRESS="root@192.168.7.2"
7 BBB_PATH="~/BeagleRT" 7 BBB_PATH="~/BeagleRT"
8 COMMAND_ARGS= 8 COMMAND_ARGS=
9 RUN_IN_FOREGROUND=0
9 10
10 function usage 11 function usage
11 { 12 {
12 THIS_SCRIPT=`basename "$0"` 13 THIS_SCRIPT=`basename "$0"`
13 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args]" 14 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-f]"
14 15
15 echo " 16 echo "
16 This script runs a previously compiled BeagleRT project on the 17 This script runs a previously compiled BeagleRT project on the
17 BeagleBone Black. The -b option changes the default path, which 18 BeagleBone Black. The -b option changes the default path, which
18 is otherwise $BBB_PATH. The -c option passes command-line arguments 19 is otherwise $BBB_PATH. The -c option passes command-line arguments
19 to the BeagleRT program; enclose the argument string in quotes." 20 to the BeagleRT program; enclose the argument string in quotes.
21 The -f argument runs the project in the foreground of the current terminal,
22 within a screen session that can be detached later."
20 } 23 }
21 24
22 OPTIND=1 25 OPTIND=1
23 26
24 while getopts "b:c:h" opt; do 27 while getopts "b:c:fh" opt; do
25 case $opt in 28 case $opt in
26 b) BBB_PATH=$OPTARG 29 b) BBB_PATH=$OPTARG
27 ;; 30 ;;
28 c) COMMAND_ARGS=$OPTARG 31 c) COMMAND_ARGS=$OPTARG
32 ;;
33 f) RUN_IN_FOREGROUND=1
29 ;; 34 ;;
30 h|\?) usage 35 h|\?) usage
31 exit 1 36 exit 1
32 esac 37 esac
33 done 38 done
34 39
35 shift $((OPTIND-1)) 40 shift $((OPTIND-1))
36 41
37 echo "Running BeagleRT..." 42 echo "Running BeagleRT..."
38 ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" 43 if [ $RUN_IN_FOREGROUND -eq 0 ]
44 then
45 ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
46 else
47 ssh -t $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS"
48 fi