view scripts/.bela_common @ 518:c774bd8ad108 prerelease

Set date works on windows
author oromoiluig <giuliomoro@yahoo.it>
date Wed, 22 Jun 2016 17:51:52 +0100
parents 7eb66c7898cb
children 42f6af3a5f1d
line wrap: on
line source
[ -z "$BBB_USER" ] && BBB_USER="root"
[ -z "$BBB_HOSTNAME" ] && BBB_HOSTNAME="192.168.7.2"
[ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="$BBB_USER@$BBB_HOSTNAME"
[ -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])"; return 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])"; return 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"
}

check_board_alive(){
	printf "Checking the board is up and running at $BBB_ADDRESS..."
	ssh -o ConnectTimeout=10 $BBB_ADDRESS exit && printf "done\n" || {
		printf "\nERROR: the board does not respond at $BBB_ADDRESS, check that the address is correct and the board is connected.\n";
		exit 1;
	}
}