diff 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
line wrap: on
line diff
--- a/scripts/set_startup.sh	Thu Jun 09 01:11:55 2016 +0100
+++ b/scripts/set_startup.sh	Thu Jun 09 01:25:32 2016 +0100
@@ -3,14 +3,20 @@
 # This script enables or disables running BeagleRT when the board starts
 # up.
 
-BBB_ADDRESS="root@192.168.7.2"
-BBB_PATH="/root/BeagleRT"
+[ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
+[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/"
+[ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="BeagleRT"
+[ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
+[ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
+[ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
+[ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
+[ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
+[ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
+[ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
 ENABLE_STARTUP=1
-COMMAND_ARGS=
 RUN_IN_LOOP=0
 
 # This path is hard-coded in the BeagleRT image at present.
-BBB_STARTUP_SCRIPT="/root/BeagleRT_startup.sh"
 
 function usage
 {
@@ -20,9 +26,10 @@
     echo "
     This script enables (by default) or disables running the BeagleRT
     project at startup. The -n option disables auto-startup, otherwise
-    auto-startup is enabled. The -b option changes the default path, which
-    is otherwise $BBB_PATH. The -c option passes command-line arguments to
-    the BeagleRT program; enclose the argument string in quotes.
+    auto-startup is enabled. The -b option changes the name of the project to
+    set on startup, which is otherwise $BBB_DEFAULT_PROJECT_NAME. The -c option 
+    passes command-line arguments to the BeagleRT program; enclose the argument 
+    string in quotes.
     The -l option runs the BeagleRT program in a loop, restarting
     automatically in the event of a crash."
 }
@@ -31,7 +38,7 @@
 
 while getopts "b:c:nlh" opt; do
     case $opt in
-        b)            BBB_PATH=$OPTARG
+        b)            BBB_PROJECT_NAME=$OPTARG
                       ;;
         c)            COMMAND_ARGS=$OPTARG
                       ;;
@@ -46,31 +53,16 @@
 
 shift $((OPTIND-1))
 
+MAKE_COMMAND="make -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME CL=\"$OPTARG\""
 if [ $ENABLE_STARTUP -eq 0 ]
 then
     echo "Disabling BeagleRT at startup..."
-
-    ssh $BBB_ADDRESS "echo \"#!/bin/sh
-#
-# This file is autogenerated by BeagleRT. Do not edit!
-
-# Run on startup disabled -- nothing to do here\" > $BBB_STARTUP_SCRIPT"
-
-else
+    ssh $BBB_ADDRESS "$MAKE_COMMAND nostartup"
+elif [ $RUN_IN_LOOP -eq 1 ]
+then    
     echo "Enabling BeagleRT at startup..."
-  
-    SCRIPT_PRERUN=
-    SCRIPT_POSTRUN=
-    if [ $RUN_IN_LOOP -ne 0 ] ; then
-	SCRIPT_PRERUN="bash -c \\\"while sleep 0.5 ; do"
-	SCRIPT_POSTRUN=" ; done \\\" "
-    fi
-
-    ssh $BBB_ADDRESS "echo \"#!/bin/sh
-#
-# This file is autogenerated by BeagleRT. Do not edit!
-
-echo Running BeagleRT...
-screen -S BeagleRT -d -m $SCRIPT_PRERUN $BBB_PATH/BeagleRT $COMMAND_ARGS $SCRIPT_POSTRUN\" > $BBB_STARTUP_SCRIPT"
-
+    ssh $BBB_ADDRESS "$MAKE_COMMAND startuploop" 
+else 
+    echo "Enabling BeagleRT at startup..."
+    ssh $BBB_ADDRESS "$MAKE_COMMAND startup" 
 fi