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@462
|
6 SCRIPTDIR=$(dirname "$0")
|
giuliomoro@462
|
7 [ -z $SCRIPTDIR ] && SCRIPTDIR="./" || SCRIPTDIR=$SCRIPTDIR/
|
giuliomoro@462
|
8 . $SCRIPTDIR.bela_common || { echo "You must be in Bela/scripts to run these scripts" | exit 1; }
|
giuliomoro@462
|
9
|
andrewm@59
|
10 ENABLE_STARTUP=1
|
giuliomoro@509
|
11 RUN_IN_LOOP=1
|
andrewm@59
|
12
|
giuliomoro@377
|
13 # This path is hard-coded in the Bela image at present.
|
andrewm@59
|
14
|
giuliomoro@430
|
15 usage()
|
andrewm@59
|
16 {
|
andrewm@59
|
17 THIS_SCRIPT=`basename "$0"`
|
giuliomoro@509
|
18 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-s]"
|
andrewm@59
|
19
|
andrewm@59
|
20 echo "
|
giuliomoro@377
|
21 This script enables (by default) or disables running the Bela
|
andrewm@59
|
22 project at startup. The -n option disables auto-startup, otherwise
|
giuliomoro@363
|
23 auto-startup is enabled. The -b option changes the name of the project to
|
giuliomoro@363
|
24 set on startup, which is otherwise $BBB_DEFAULT_PROJECT_NAME. The -c option
|
giuliomoro@377
|
25 passes command-line arguments to the Bela program; enclose the argument
|
giuliomoro@363
|
26 string in quotes.
|
giuliomoro@509
|
27 The -s option runs the Bela program in single-shot mode.
|
giuliomoro@509
|
28 By default, instead, the program is restarted automatically in the event of a crash."
|
andrewm@59
|
29 }
|
andrewm@59
|
30
|
andrewm@59
|
31 OPTIND=1
|
andrewm@59
|
32
|
giuliomoro@509
|
33 while getopts "b:c:nhs" opt; do
|
andrewm@59
|
34 case $opt in
|
giuliomoro@363
|
35 b) BBB_PROJECT_NAME=$OPTARG
|
andrewm@59
|
36 ;;
|
andrewm@60
|
37 c) COMMAND_ARGS=$OPTARG
|
andrewm@60
|
38 ;;
|
andrewm@59
|
39 n) ENABLE_STARTUP=0
|
andrewm@59
|
40 ;;
|
giuliomoro@509
|
41 s) RUN_IN_LOOP=0
|
andrewm@62
|
42 ;;
|
andrewm@59
|
43 h|\?) usage
|
andrewm@59
|
44 exit 1
|
andrewm@59
|
45 esac
|
andrewm@59
|
46 done
|
andrewm@59
|
47
|
andrewm@59
|
48 shift $((OPTIND-1))
|
andrewm@59
|
49
|
giuliomoro@422
|
50 MAKE_COMMAND="make --no-print-directory -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME CL=\"$OPTARG\""
|
andrewm@59
|
51 if [ $ENABLE_STARTUP -eq 0 ]
|
andrewm@59
|
52 then
|
giuliomoro@363
|
53 ssh $BBB_ADDRESS "$MAKE_COMMAND nostartup"
|
giuliomoro@363
|
54 elif [ $RUN_IN_LOOP -eq 1 ]
|
giuliomoro@363
|
55 then
|
giuliomoro@363
|
56 ssh $BBB_ADDRESS "$MAKE_COMMAND startuploop"
|
giuliomoro@363
|
57 else
|
giuliomoro@363
|
58 ssh $BBB_ADDRESS "$MAKE_COMMAND startup"
|
giuliomoro@328
|
59 fi
|