giuliomoro@516
|
1 [ -z "$BBB_USER" ] && BBB_USER="root"
|
giuliomoro@516
|
2 [ -z "$BBB_HOSTNAME" ] && BBB_HOSTNAME="192.168.7.2"
|
giuliomoro@516
|
3 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="$BBB_USER@$BBB_HOSTNAME"
|
giuliomoro@445
|
4 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
|
giuliomoro@445
|
5 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
|
giuliomoro@445
|
6 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
|
giuliomoro@445
|
7 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
|
giuliomoro@445
|
8 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
|
giuliomoro@445
|
9 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
|
giuliomoro@445
|
10 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
|
giuliomoro@445
|
11 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
|
giuliomoro@445
|
12 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
|
giuliomoro@445
|
13
|
giuliomoro@445
|
14 trap "echo; exit 0;" 2 9
|
giuliomoro@445
|
15 folder_has_changed(){
|
giuliomoro@447
|
16 [ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; return 1; }
|
giuliomoro@445
|
17 [ -z "$3" ] && FILTER="." || FILTER="$3"
|
giuliomoro@445
|
18 find "$1" -type f -newer "$2" | grep "$FILTER"
|
giuliomoro@445
|
19 return $?
|
giuliomoro@445
|
20 }
|
giuliomoro@445
|
21
|
giuliomoro@445
|
22 wait_for_change(){
|
giuliomoro@447
|
23 [ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; return 1; }
|
giuliomoro@445
|
24 [ -z "$4" ] && SLEEP=0.5 || SLEEP="$4"
|
giuliomoro@445
|
25 while ! folder_has_changed "$1" "$2" "$3"
|
giuliomoro@445
|
26 do
|
giuliomoro@445
|
27 sleep $SLEEP;
|
giuliomoro@445
|
28 done
|
giuliomoro@445
|
29 }
|
giuliomoro@445
|
30
|
giuliomoro@445
|
31 set_date(){
|
giuliomoro@445
|
32 # an optional parameter will be executed as part of the same ssh session
|
giuliomoro@518
|
33 ssh $BBB_ADDRESS "date -s \"`date '+%Y%m%d %T %z'`\" > /dev/null; $1"
|
giuliomoro@445
|
34 }
|
giuliomoro@515
|
35
|
giuliomoro@515
|
36 check_board_alive(){
|
giuliomoro@515
|
37 printf "Checking the board is up and running at $BBB_ADDRESS..."
|
giuliomoro@515
|
38 ssh -o ConnectTimeout=10 $BBB_ADDRESS exit && printf "done\n" || {
|
giuliomoro@515
|
39 printf "\nERROR: the board does not respond at $BBB_ADDRESS, check that the address is correct and the board is connected.\n";
|
giuliomoro@515
|
40 exit 1;
|
giuliomoro@515
|
41 }
|
giuliomoro@515
|
42 }
|