blob: 20ed64549fd63a66f87ed4d56cb5517019c7b885 [file] [log] [blame]
Brian Silvermand94642c2014-03-27 18:21:41 -07001#!/bin/bash
2#set -x
3
4# Downloads code to the prime in a way that avoids clashing too badly with
5# starter.
6# Requires 1 argument (the directory to download).
7
8GET_IP=$(dirname $0)/get_ip
9SUM=md5sum
10FROM_DIR=$1
11TO_DIR=/home/driver/robot_code/bin
12TMPDIR=/tmp/aos_downloader
13TARGET=driver@$(${GET_IP} prime)
14
15SUMS=$(cd ${FROM_DIR} && ${SUM} *)
16
17TO_DOWNLOAD=$(ssh ${TARGET} "rm -rf ${TMPDIR} && mkdir ${TMPDIR} && cd ${TO_DIR} && echo '${SUMS}' | ${SUM} --check --quiet |& grep -F FAILED | sed 's/^\\(.*\\): FAILED"'$'"/\\1/g'")
18
19if [[ -z "${TO_DOWNLOAD}" ]]; then
20 echo "Nothing to download"
21 exit 0
22fi
23
24# Compression seems to make it go faster even when the network isn't the
25# bottleneck with a BBB. Maybe it's because ethernet on the BBB uses so much
26# CPU?
27( cd ${FROM_DIR} && scp -o "Compression yes" ${TO_DOWNLOAD} ${TARGET}:${TMPDIR} )
28ssh ${TARGET} "mv ${TMPDIR}/* ${TO_DIR} && echo 'Done moving new executables into place' && ionice -c 3 bash -c 'sync && sync && sync'"