brians | 261847b | 2013-02-26 01:56:51 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # This script provides a central location for getting IP addresses. It uses |
| 4 | # output/ip_base.txt as the first 3 parts and then adds on whatever is |
| 5 | # correct for its first argument (fitpc or robot). |
| 6 | # It will create output/ip_base.txt with a default value if it does not already |
| 7 | # exist. |
| 8 | |
| 9 | FILE=`dirname $0`/../../output/ip_base.txt |
| 10 | |
| 11 | if [[ ! -e ${FILE} ]]; then |
| 12 | mkdir -p `dirname ${FILE}` |
| 13 | echo '10.9.71' > ${FILE} |
| 14 | fi |
| 15 | |
| 16 | BASE=`cat ${FILE}` |
| 17 | |
| 18 | case $1 in |
| 19 | fitpc) |
| 20 | # This is the IP address that we use for our fitpc. |
| 21 | echo ${BASE}.179 ;; |
| 22 | robot) |
| 23 | # This is the IP address that the cRIO has to be on. |
| 24 | echo ${BASE}.2 ;; |
| 25 | *) |
| 26 | echo "Unknown IP address $1. Returning ${BASE}.0 instead." 1>&2 |
| 27 | echo ${BASE}.0 |
| 28 | esac |