giuliomoro@425: #!/bin/sh andrewm@59: # giuliomoro@377: # This script enables or disables running Bela when the board starts andrewm@59: # up. andrewm@59: giuliomoro@462: SCRIPTDIR=$(dirname "$0") giuliomoro@462: [ -z $SCRIPTDIR ] && SCRIPTDIR="./" || SCRIPTDIR=$SCRIPTDIR/ giuliomoro@462: . $SCRIPTDIR.bela_common || { echo "You must be in Bela/scripts to run these scripts" | exit 1; } giuliomoro@462: andrewm@59: ENABLE_STARTUP=1 andrewm@62: RUN_IN_LOOP=0 andrewm@59: giuliomoro@377: # This path is hard-coded in the Bela image at present. andrewm@59: giuliomoro@430: usage() andrewm@59: { andrewm@59: THIS_SCRIPT=`basename "$0"` andrewm@62: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]" andrewm@59: andrewm@59: echo " giuliomoro@377: This script enables (by default) or disables running the Bela andrewm@59: project at startup. The -n option disables auto-startup, otherwise giuliomoro@363: auto-startup is enabled. The -b option changes the name of the project to giuliomoro@363: set on startup, which is otherwise $BBB_DEFAULT_PROJECT_NAME. The -c option giuliomoro@377: passes command-line arguments to the Bela program; enclose the argument giuliomoro@363: string in quotes. giuliomoro@377: The -l option runs the Bela program in a loop, restarting andrewm@62: automatically in the event of a crash." andrewm@59: } andrewm@59: andrewm@59: OPTIND=1 andrewm@59: andrewm@62: while getopts "b:c:nlh" opt; do andrewm@59: case $opt in giuliomoro@363: b) BBB_PROJECT_NAME=$OPTARG andrewm@59: ;; andrewm@60: c) COMMAND_ARGS=$OPTARG andrewm@60: ;; andrewm@59: n) ENABLE_STARTUP=0 andrewm@59: ;; andrewm@62: l) RUN_IN_LOOP=1 andrewm@62: ;; andrewm@59: h|\?) usage andrewm@59: exit 1 andrewm@59: esac andrewm@59: done andrewm@59: andrewm@59: shift $((OPTIND-1)) andrewm@59: giuliomoro@422: MAKE_COMMAND="make --no-print-directory -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME CL=\"$OPTARG\"" andrewm@59: if [ $ENABLE_STARTUP -eq 0 ] andrewm@59: then giuliomoro@363: ssh $BBB_ADDRESS "$MAKE_COMMAND nostartup" giuliomoro@363: elif [ $RUN_IN_LOOP -eq 1 ] giuliomoro@363: then giuliomoro@363: ssh $BBB_ADDRESS "$MAKE_COMMAND startuploop" giuliomoro@363: else giuliomoro@363: ssh $BBB_ADDRESS "$MAKE_COMMAND startup" giuliomoro@328: fi