diff scripts/.bela_common @ 445:2b09be3fb0f2 prerelease

Re-implemented watch for build_heavy ... added .bela_common file for shared config and utilities
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 19 Jun 2016 03:28:53 +0100
parents
children 86591d203c78
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/.bela_common	Sun Jun 19 03:28:53 2016 +0100
@@ -0,0 +1,32 @@
+[ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
+[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
+[ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
+[ -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
+
+trap "echo; exit 0;" 2 9
+folder_has_changed(){
+	[ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; exit 1; }
+	[ -z "$3" ] && FILTER="." || FILTER="$3"
+	find "$1" -type f -newer "$2" | grep "$FILTER"
+	return $?
+}
+
+wait_for_change(){
+	[ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; exit 1; }
+	[ -z "$4" ] && SLEEP=0.5 || SLEEP="$4"
+	while ! folder_has_changed "$1" "$2" "$3"
+	do
+		sleep $SLEEP;	
+	done
+}
+
+set_date(){
+# an optional parameter will be executed as part of the same ssh session
+	ssh $BBB_ADDRESS "date -s \"`date '+%Y%m%d %T %Z'`\" > /dev/null; $1"
+}