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