comparison scripts/set_startup.sh @ 108:3068421c0737 ultra-staging

Merged default into ultra-staging
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 18 Aug 2015 00:35:15 +0100
parents a11e23f4e6af
children abd7795dad5d
comparison
equal deleted inserted replaced
54:d3f869b98147 108:3068421c0737
1 #!/bin/bash
2 #
3 # This script enables or disables running BeagleRT when the board starts
4 # up.
5
6 BBB_ADDRESS="root@192.168.7.2"
7 BBB_PATH="/root/BeagleRT"
8 ENABLE_STARTUP=1
9 COMMAND_ARGS=
10 RUN_IN_LOOP=0
11
12 # This path is hard-coded in the BeagleRT image at present.
13 BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh"
14
15 function usage
16 {
17 THIS_SCRIPT=`basename "$0"`
18 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]"
19
20 echo "
21 This script enables (by default) or disables running the BeagleRT
22 project at startup. The -n option disables auto-startup, otherwise
23 auto-startup is enabled. The -b option changes the default path, which
24 is otherwise $BBB_PATH. The -c option passes command-line arguments to
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."
28 }
29
30 OPTIND=1
31
32 while getopts "b:c:nlh" opt; do
33 case $opt in
34 b) BBB_PATH=$OPTARG
35 ;;
36 c) COMMAND_ARGS=$OPTARG
37 ;;
38 n) ENABLE_STARTUP=0
39 ;;
40 l) RUN_IN_LOOP=1
41 ;;
42 h|\?) usage
43 exit 1
44 esac
45 done
46
47 shift $((OPTIND-1))
48
49 if [ $ENABLE_STARTUP -eq 0 ]
50 then
51 echo "Disabling BeagleRT at startup..."
52
53 ssh $BBB_ADDRESS "echo \"#!/bin/sh
54 #
55 # This file is autogenerated by BeagleRT. Do not edit!
56
57 # Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT"
58
59 else
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
68
69 ssh $BBB_ADDRESS "echo \"#!/bin/sh
70 #
71 # This file is autogenerated by BeagleRT. Do not edit!
72
73 echo Running BeagleRT...
74 screen -S BeagleRT -d -m $SCRIPT_PRERUN $BBB_PATH/BeagleRT $COMMAND_ARGS $SCRIPT_POSTRUN\" > $BBB_STARTUP_SCRIPT"
75
76 fi