blob: 584d09e5967ca7927293ed1d874e4124a0a05d3d [file] [log] [blame]
Michael Schuh5a1a7582019-03-01 13:03:47 -08001#!/bin/bash
2
3set -e
4
5echo ""
6echo "USAGE: $0 ODROID_ip_address"
7echo "Example: $0 10.9.71.179"
8echo "Example: $0 10.99.71.179"
9echo ""
10
11if [ $# != 1 ]
12 then
13 echo "Illegal number of parameters"
14 exit
15fi
16
17if [[ $1 == -*[hH]* ]]
18 then
19 exit
20fi
21
22# Get the script directory (from https://devhints.io/bash)
23DIR="${0%/*}"
24
25# Move into the script directory
26cd "${DIR}"
27echo "# Working in `pwd`"
28
29ODROID_IP_ADDRESS=$1
30ODROID="root@${ODROID_IP_ADDRESS}"
31# Get the IP address of the roboRIO from the ODROID IP address
32# This is needed to properly configure supervisorctl on the ODROID
33# for image_streamer to communicate with the roboRIO.
34ROBORIO=`echo ${ODROID_IP_ADDRESS} | sed 's/\.[0-9]*$/.2/'`
35
36echo "# Using ODORID ${ODROID}"
37echo "# Using roboRIO ${ROBORIO}"
38
39# This builds the ODROID image_streamer code.
40echo -e "\n# Building image_streamer"
41(
42set -x
43bazel build -c opt //y2019/image_streamer:image_streamer --cpu=armhf-debian
44)
45
46echo -e "\n# Copy files to ODROID"
47(
48set -x
49rsync -av --progress ../../bazel-bin/y2019/image_streamer/image_streamer "${ODROID}":.
50rsync -av --progress README_ODROID_setup.txt "${ODROID}":.
51rsync -av --progress vision.conf "${ODROID}":/etc/supervisor/conf.d/
52)
53
54echo "# Make sure supervisorctl has the correct IP address."
55(
56set -x
57ssh "${ODROID}" sed -i -e "'/image_streamer/ s/10.9.71.2/${ROBORIO}/'" /etc/supervisor/conf.d/vision.conf
58
59ssh "${ODROID}" sync
60)
61
62echo -e "\nCan't restart image_streamer with supervisorctl because the USB devices don't come up reliably..." >&2
63echo "Restart the ODROID now" >&2