comparison scripts/set_startup.sh @ 363:6e428d6b57ef prerelease

updated set_startup
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 09 Jun 2016 01:25:32 +0100
parents abd7795dad5d
children a430a16d2c02
comparison
equal deleted inserted replaced
362:0372fb8e8309 363:6e428d6b57ef
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # This script enables or disables running BeagleRT when the board starts 3 # This script enables or disables running BeagleRT when the board starts
4 # up. 4 # up.
5 5
6 BBB_ADDRESS="root@192.168.7.2" 6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
7 BBB_PATH="/root/BeagleRT" 7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/"
8 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="BeagleRT"
9 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
10 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
11 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
12 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
13 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
14 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
15 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
8 ENABLE_STARTUP=1 16 ENABLE_STARTUP=1
9 COMMAND_ARGS=
10 RUN_IN_LOOP=0 17 RUN_IN_LOOP=0
11 18
12 # This path is hard-coded in the BeagleRT image at present. 19 # This path is hard-coded in the BeagleRT image at present.
13 BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh"
14 20
15 function usage 21 function usage
16 { 22 {
17 THIS_SCRIPT=`basename "$0"` 23 THIS_SCRIPT=`basename "$0"`
18 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]" 24 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] [-l]"
19 25
20 echo " 26 echo "
21 This script enables (by default) or disables running the BeagleRT 27 This script enables (by default) or disables running the BeagleRT
22 project at startup. The -n option disables auto-startup, otherwise 28 project at startup. The -n option disables auto-startup, otherwise
23 auto-startup is enabled. The -b option changes the default path, which 29 auto-startup is enabled. The -b option changes the name of the project to
24 is otherwise $BBB_PATH. The -c option passes command-line arguments to 30 set on startup, which is otherwise $BBB_DEFAULT_PROJECT_NAME. The -c option
25 the BeagleRT program; enclose the argument string in quotes. 31 passes command-line arguments to the BeagleRT program; enclose the argument
32 string in quotes.
26 The -l option runs the BeagleRT program in a loop, restarting 33 The -l option runs the BeagleRT program in a loop, restarting
27 automatically in the event of a crash." 34 automatically in the event of a crash."
28 } 35 }
29 36
30 OPTIND=1 37 OPTIND=1
31 38
32 while getopts "b:c:nlh" opt; do 39 while getopts "b:c:nlh" opt; do
33 case $opt in 40 case $opt in
34 b) BBB_PATH=$OPTARG 41 b) BBB_PROJECT_NAME=$OPTARG
35 ;; 42 ;;
36 c) COMMAND_ARGS=$OPTARG 43 c) COMMAND_ARGS=$OPTARG
37 ;; 44 ;;
38 n) ENABLE_STARTUP=0 45 n) ENABLE_STARTUP=0
39 ;; 46 ;;
44 esac 51 esac
45 done 52 done
46 53
47 shift $((OPTIND-1)) 54 shift $((OPTIND-1))
48 55
56 MAKE_COMMAND="make -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME CL=\"$OPTARG\""
49 if [ $ENABLE_STARTUP -eq 0 ] 57 if [ $ENABLE_STARTUP -eq 0 ]
50 then 58 then
51 echo "Disabling BeagleRT at startup..." 59 echo "Disabling BeagleRT at startup..."
52 60 ssh $BBB_ADDRESS "$MAKE_COMMAND nostartup"
53 ssh $BBB_ADDRESS "echo \"#!/bin/sh 61 elif [ $RUN_IN_LOOP -eq 1 ]
54 # 62 then
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..." 63 echo "Enabling BeagleRT at startup..."
61 64 ssh $BBB_ADDRESS "$MAKE_COMMAND startuploop"
62 SCRIPT_PRERUN= 65 else
63 SCRIPT_POSTRUN= 66 echo "Enabling BeagleRT at startup..."
64 if [ $RUN_IN_LOOP -ne 0 ] ; then 67 ssh $BBB_ADDRESS "$MAKE_COMMAND startup"
65 SCRIPT_PRERUN="bash -c \\\"while sleep 0.5 ; 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 68 fi