giuliomoro@425
|
1 #!/bin/sh
|
andrewm@59
|
2 #
|
giuliomoro@377
|
3 # This script enables or disables running Bela when the board starts
|
andrewm@59
|
4 # up.
|
andrewm@59
|
5
|
giuliomoro@363
|
6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
|
giuliomoro@377
|
7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
|
giuliomoro@377
|
8 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
|
giuliomoro@363
|
9 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
|
giuliomoro@363
|
10 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
|
giuliomoro@363
|
11 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
|
giuliomoro@363
|
12 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
|
giuliomoro@363
|
13 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
|
giuliomoro@363
|
14 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
|
giuliomoro@363
|
15 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
|
andrewm@59
|
16 ENABLE_STARTUP=1
|
andrewm@62
|
17 RUN_IN_LOOP=0
|
andrewm@59
|
18
|
giuliomoro@377
|
19 # This path is hard-coded in the Bela image at present.
|
andrewm@59
|
20
|
andrewm@59
|
21 function usage
|
andrewm@59
|
22 {
|
andrewm@59
|
23 THIS_SCRIPT=`basename "$0"`
|
andrewm@62
|
24 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]"
|
andrewm@59
|
25
|
andrewm@59
|
26 echo "
|
giuliomoro@377
|
27 This script enables (by default) or disables running the Bela
|
andrewm@59
|
28 project at startup. The -n option disables auto-startup, otherwise
|
giuliomoro@363
|
29 auto-startup is enabled. The -b option changes the name of the project to
|
giuliomoro@363
|
30 set on startup, which is otherwise $BBB_DEFAULT_PROJECT_NAME. The -c option
|
giuliomoro@377
|
31 passes command-line arguments to the Bela program; enclose the argument
|
giuliomoro@363
|
32 string in quotes.
|
giuliomoro@377
|
33 The -l option runs the Bela program in a loop, restarting
|
andrewm@62
|
34 automatically in the event of a crash."
|
andrewm@59
|
35 }
|
andrewm@59
|
36
|
andrewm@59
|
37 OPTIND=1
|
andrewm@59
|
38
|
andrewm@62
|
39 while getopts "b:c:nlh" opt; do
|
andrewm@59
|
40 case $opt in
|
giuliomoro@363
|
41 b) BBB_PROJECT_NAME=$OPTARG
|
andrewm@59
|
42 ;;
|
andrewm@60
|
43 c) COMMAND_ARGS=$OPTARG
|
andrewm@60
|
44 ;;
|
andrewm@59
|
45 n) ENABLE_STARTUP=0
|
andrewm@59
|
46 ;;
|
andrewm@62
|
47 l) RUN_IN_LOOP=1
|
andrewm@62
|
48 ;;
|
andrewm@59
|
49 h|\?) usage
|
andrewm@59
|
50 exit 1
|
andrewm@59
|
51 esac
|
andrewm@59
|
52 done
|
andrewm@59
|
53
|
andrewm@59
|
54 shift $((OPTIND-1))
|
andrewm@59
|
55
|
giuliomoro@422
|
56 MAKE_COMMAND="make --no-print-directory -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME CL=\"$OPTARG\""
|
andrewm@59
|
57 if [ $ENABLE_STARTUP -eq 0 ]
|
andrewm@59
|
58 then
|
giuliomoro@363
|
59 ssh $BBB_ADDRESS "$MAKE_COMMAND nostartup"
|
giuliomoro@363
|
60 elif [ $RUN_IN_LOOP -eq 1 ]
|
giuliomoro@363
|
61 then
|
giuliomoro@363
|
62 ssh $BBB_ADDRESS "$MAKE_COMMAND startuploop"
|
giuliomoro@363
|
63 else
|
giuliomoro@363
|
64 ssh $BBB_ADDRESS "$MAKE_COMMAND startup"
|
giuliomoro@328
|
65 fi
|