Mercurial > hg > beaglert
annotate 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 |
rev | line source |
---|---|
andrewm@58 | 1 #!/bin/bash |
andrewm@58 | 2 # |
andrewm@58 | 3 # This script runs an already-compiled BeagleRT project on the |
andrewm@58 | 4 # BeagleBone Black. |
andrewm@58 | 5 |
andrewm@58 | 6 BBB_ADDRESS="root@192.168.7.2" |
andrewm@58 | 7 BBB_PATH="~/BeagleRT" |
andrewm@60 | 8 COMMAND_ARGS= |
andrewm@62 | 9 RUN_IN_FOREGROUND=0 |
andrewm@58 | 10 |
andrewm@58 | 11 function usage |
andrewm@58 | 12 { |
andrewm@58 | 13 THIS_SCRIPT=`basename "$0"` |
andrewm@62 | 14 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-f]" |
andrewm@58 | 15 |
andrewm@58 | 16 echo " |
andrewm@58 | 17 This script runs a previously compiled BeagleRT project on the |
andrewm@58 | 18 BeagleBone Black. The -b option changes the default path, which |
andrewm@60 | 19 is otherwise $BBB_PATH. The -c option passes command-line arguments |
andrewm@62 | 20 to the BeagleRT program; enclose the argument string in quotes. |
andrewm@62 | 21 The -f argument runs the project in the foreground of the current terminal, |
andrewm@62 | 22 within a screen session that can be detached later." |
andrewm@58 | 23 } |
andrewm@58 | 24 |
andrewm@58 | 25 OPTIND=1 |
andrewm@58 | 26 |
andrewm@62 | 27 while getopts "b:c:fh" opt; do |
andrewm@58 | 28 case $opt in |
andrewm@58 | 29 b) BBB_PATH=$OPTARG |
andrewm@58 | 30 ;; |
andrewm@60 | 31 c) COMMAND_ARGS=$OPTARG |
andrewm@60 | 32 ;; |
andrewm@62 | 33 f) RUN_IN_FOREGROUND=1 |
andrewm@62 | 34 ;; |
andrewm@58 | 35 h|\?) usage |
andrewm@58 | 36 exit 1 |
andrewm@58 | 37 esac |
andrewm@58 | 38 done |
andrewm@58 | 39 |
andrewm@58 | 40 shift $((OPTIND-1)) |
andrewm@58 | 41 |
andrewm@58 | 42 echo "Running BeagleRT..." |
andrewm@62 | 43 if [ $RUN_IN_FOREGROUND -eq 0 ] |
andrewm@62 | 44 then |
andrewm@62 | 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" |
andrewm@62 | 46 else |
andrewm@62 | 47 ssh -t $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" |
andrewm@62 | 48 fi |