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@363: [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" giuliomoro@377: [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/" giuliomoro@377: [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela" giuliomoro@363: [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1 giuliomoro@363: [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS= giuliomoro@363: [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1 giuliomoro@363: [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0 giuliomoro@363: [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" giuliomoro@363: [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject" giuliomoro@363: [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME 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: andrewm@59: function 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