andrewm@59: #!/bin/bash andrewm@59: # andrewm@59: # This script enables or disables running BeagleRT when the board starts andrewm@59: # up. andrewm@59: andrewm@59: BBB_ADDRESS="root@192.168.7.2" andrewm@59: BBB_PATH="/root/BeagleRT" andrewm@59: ENABLE_STARTUP=1 andrewm@60: COMMAND_ARGS= andrewm@62: RUN_IN_LOOP=0 andrewm@59: andrewm@59: # This path is hard-coded in the BeagleRT image at present. andrewm@59: BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh" 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 " andrewm@59: This script enables (by default) or disables running the BeagleRT andrewm@59: project at startup. The -n option disables auto-startup, otherwise andrewm@59: auto-startup is enabled. The -b option changes the default path, which andrewm@60: is otherwise $BBB_PATH. The -c option passes command-line arguments to andrewm@62: the BeagleRT program; enclose the argument string in quotes. andrewm@62: The -l option runs the BeagleRT 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 andrewm@59: b) BBB_PATH=$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: andrewm@59: if [ $ENABLE_STARTUP -eq 0 ] andrewm@59: then andrewm@59: echo "Disabling BeagleRT at startup..." andrewm@59: andrewm@59: ssh $BBB_ADDRESS "echo \"#!/bin/sh andrewm@59: # andrewm@59: # This file is autogenerated by BeagleRT. Do not edit! andrewm@59: andrewm@59: # Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT" andrewm@59: andrewm@59: else andrewm@59: echo "Enabling BeagleRT at startup..." andrewm@62: andrewm@62: SCRIPT_PRERUN= andrewm@62: SCRIPT_POSTRUN= andrewm@62: if [ $RUN_IN_LOOP -ne 0 ] ; then andrewm@62: SCRIPT_PRERUN="bash -c \\\"while true ; do" andrewm@62: SCRIPT_POSTRUN=" ; done \\\" " andrewm@62: fi andrewm@59: andrewm@59: ssh $BBB_ADDRESS "echo \"#!/bin/sh andrewm@59: # andrewm@59: # This file is autogenerated by BeagleRT. Do not edit! andrewm@59: andrewm@59: echo Running BeagleRT... andrewm@62: screen -S BeagleRT -d -m $SCRIPT_PRERUN $BBB_PATH/BeagleRT $COMMAND_ARGS $SCRIPT_POSTRUN\" > $BBB_STARTUP_SCRIPT" andrewm@59: andrewm@59: fi