comparison scripts/run_project.sh @ 108:3068421c0737 ultra-staging

Merged default into ultra-staging
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 18 Aug 2015 00:35:15 +0100
parents d41631e0fe0e
children ccd084cf22ac
comparison
equal deleted inserted replaced
54:d3f869b98147 108:3068421c0737
1 #!/bin/bash
2 #
3 # This script runs an already-compiled BeagleRT project on the
4 # BeagleBone Black.
5
6 BBB_ADDRESS="root@192.168.7.2"
7 BBB_PATH="~/BeagleRT"
8 COMMAND_ARGS=
9 RUN_IN_FOREGROUND=0
10 RUN_WITHOUT_SCREEN=0
11
12 function usage
13 {
14 THIS_SCRIPT=`basename "$0"`
15 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]"
16
17 echo "
18 This script runs a previously compiled BeagleRT project on the
19 BeagleBone Black. The -b option changes the default path, which
20 is otherwise $BBB_PATH. The -c option passes command-line arguments
21 to the BeagleRT program; enclose the argument string in quotes.
22
23 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
25 the project in the foreground of the current terminal, without screen, so
26 the output can be piped to another destination."
27 }
28
29 OPTIND=1
30
31 while getopts "b:c:fFh" opt; do
32 case $opt in
33 b) BBB_PATH=$OPTARG
34 ;;
35 c) COMMAND_ARGS=$OPTARG
36 ;;
37 f) RUN_IN_FOREGROUND=1
38 ;;
39 F) RUN_WITHOUT_SCREEN=1
40 ;;
41 h|\?) usage
42 exit 1
43 esac
44 done
45
46 shift $((OPTIND-1))
47
48 echo "Running BeagleRT..."
49 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
50 then
51 ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; $BBB_PATH/BeagleRT $COMMAND_ARGS"
52 elif [ $RUN_IN_FOREGROUND -eq 0 ]
53 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"
55 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"
57 fi