Mercurial > hg > beaglert
comparison scripts/set_startup.sh @ 62:a11e23f4e6af newapi
Added script options for running in a loop at startup (needs further support for stopping) and running the project in the foreground
author | andrewm |
---|---|
date | Wed, 15 Jul 2015 19:40:15 +0100 |
parents | ad6b2767beaf |
children | abd7795dad5d |
comparison
equal
deleted
inserted
replaced
61:afc593f7469e | 62:a11e23f4e6af |
---|---|
5 | 5 |
6 BBB_ADDRESS="root@192.168.7.2" | 6 BBB_ADDRESS="root@192.168.7.2" |
7 BBB_PATH="/root/BeagleRT" | 7 BBB_PATH="/root/BeagleRT" |
8 ENABLE_STARTUP=1 | 8 ENABLE_STARTUP=1 |
9 COMMAND_ARGS= | 9 COMMAND_ARGS= |
10 RUN_IN_LOOP=0 | |
10 | 11 |
11 # This path is hard-coded in the BeagleRT image at present. | 12 # This path is hard-coded in the BeagleRT image at present. |
12 BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh" | 13 BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh" |
13 | 14 |
14 function usage | 15 function usage |
15 { | 16 { |
16 THIS_SCRIPT=`basename "$0"` | 17 THIS_SCRIPT=`basename "$0"` |
17 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n]" | 18 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]" |
18 | 19 |
19 echo " | 20 echo " |
20 This script enables (by default) or disables running the BeagleRT | 21 This script enables (by default) or disables running the BeagleRT |
21 project at startup. The -n option disables auto-startup, otherwise | 22 project at startup. The -n option disables auto-startup, otherwise |
22 auto-startup is enabled. The -b option changes the default path, which | 23 auto-startup is enabled. The -b option changes the default path, which |
23 is otherwise $BBB_PATH. The -c option passes command-line arguments to | 24 is otherwise $BBB_PATH. The -c option passes command-line arguments to |
24 the BeagleRT program; enclose the argument string in quotes." | 25 the BeagleRT program; enclose the argument string in quotes. |
26 The -l option runs the BeagleRT program in a loop, restarting | |
27 automatically in the event of a crash." | |
25 } | 28 } |
26 | 29 |
27 OPTIND=1 | 30 OPTIND=1 |
28 | 31 |
29 while getopts "b:c:nh" opt; do | 32 while getopts "b:c:nlh" opt; do |
30 case $opt in | 33 case $opt in |
31 b) BBB_PATH=$OPTARG | 34 b) BBB_PATH=$OPTARG |
32 ;; | 35 ;; |
33 c) COMMAND_ARGS=$OPTARG | 36 c) COMMAND_ARGS=$OPTARG |
34 ;; | 37 ;; |
35 n) ENABLE_STARTUP=0 | 38 n) ENABLE_STARTUP=0 |
39 ;; | |
40 l) RUN_IN_LOOP=1 | |
36 ;; | 41 ;; |
37 h|\?) usage | 42 h|\?) usage |
38 exit 1 | 43 exit 1 |
39 esac | 44 esac |
40 done | 45 done |
51 | 56 |
52 # Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT" | 57 # Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT" |
53 | 58 |
54 else | 59 else |
55 echo "Enabling BeagleRT at startup..." | 60 echo "Enabling BeagleRT at startup..." |
61 | |
62 SCRIPT_PRERUN= | |
63 SCRIPT_POSTRUN= | |
64 if [ $RUN_IN_LOOP -ne 0 ] ; then | |
65 SCRIPT_PRERUN="bash -c \\\"while true ; do" | |
66 SCRIPT_POSTRUN=" ; done \\\" " | |
67 fi | |
56 | 68 |
57 ssh $BBB_ADDRESS "echo \"#!/bin/sh | 69 ssh $BBB_ADDRESS "echo \"#!/bin/sh |
58 # | 70 # |
59 # This file is autogenerated by BeagleRT. Do not edit! | 71 # This file is autogenerated by BeagleRT. Do not edit! |
60 | 72 |
61 echo Running BeagleRT... | 73 echo Running BeagleRT... |
62 screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS\" > $BBB_STARTUP_SCRIPT" | 74 screen -S BeagleRT -d -m $SCRIPT_PRERUN $BBB_PATH/BeagleRT $COMMAND_ARGS $SCRIPT_POSTRUN\" > $BBB_STARTUP_SCRIPT" |
63 | 75 |
64 fi | 76 fi |