annotate scripts/set_startup.sh @ 61:afc593f7469e newapi

Add ability to connect to a running BeagleRT project using screen
author andrewm
date Wed, 15 Jul 2015 19:09:18 +0100
parents ad6b2767beaf
children a11e23f4e6af
rev   line source
andrewm@59 1 #!/bin/bash
andrewm@59 2 #
andrewm@59 3 # This script enables or disables running BeagleRT when the board starts
andrewm@59 4 # up.
andrewm@59 5
andrewm@59 6 BBB_ADDRESS="root@192.168.7.2"
andrewm@59 7 BBB_PATH="/root/BeagleRT"
andrewm@59 8 ENABLE_STARTUP=1
andrewm@60 9 COMMAND_ARGS=
andrewm@59 10
andrewm@59 11 # This path is hard-coded in the BeagleRT image at present.
andrewm@59 12 BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh"
andrewm@59 13
andrewm@59 14 function usage
andrewm@59 15 {
andrewm@59 16 THIS_SCRIPT=`basename "$0"`
andrewm@60 17 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n]"
andrewm@59 18
andrewm@59 19 echo "
andrewm@59 20 This script enables (by default) or disables running the BeagleRT
andrewm@59 21 project at startup. The -n option disables auto-startup, otherwise
andrewm@59 22 auto-startup is enabled. The -b option changes the default path, which
andrewm@60 23 is otherwise $BBB_PATH. The -c option passes command-line arguments to
andrewm@60 24 the BeagleRT program; enclose the argument string in quotes."
andrewm@59 25 }
andrewm@59 26
andrewm@59 27 OPTIND=1
andrewm@59 28
andrewm@60 29 while getopts "b:c:nh" opt; do
andrewm@59 30 case $opt in
andrewm@59 31 b) BBB_PATH=$OPTARG
andrewm@59 32 ;;
andrewm@60 33 c) COMMAND_ARGS=$OPTARG
andrewm@60 34 ;;
andrewm@59 35 n) ENABLE_STARTUP=0
andrewm@59 36 ;;
andrewm@59 37 h|\?) usage
andrewm@59 38 exit 1
andrewm@59 39 esac
andrewm@59 40 done
andrewm@59 41
andrewm@59 42 shift $((OPTIND-1))
andrewm@59 43
andrewm@59 44 if [ $ENABLE_STARTUP -eq 0 ]
andrewm@59 45 then
andrewm@59 46 echo "Disabling BeagleRT at startup..."
andrewm@59 47
andrewm@59 48 ssh $BBB_ADDRESS "echo \"#!/bin/sh
andrewm@59 49 #
andrewm@59 50 # This file is autogenerated by BeagleRT. Do not edit!
andrewm@59 51
andrewm@59 52 # Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT"
andrewm@59 53
andrewm@59 54 else
andrewm@59 55 echo "Enabling BeagleRT at startup..."
andrewm@59 56
andrewm@59 57 ssh $BBB_ADDRESS "echo \"#!/bin/sh
andrewm@59 58 #
andrewm@59 59 # This file is autogenerated by BeagleRT. Do not edit!
andrewm@59 60
andrewm@59 61 echo Running BeagleRT...
andrewm@60 62 screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS\" > $BBB_STARTUP_SCRIPT"
andrewm@59 63
andrewm@59 64 fi