David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | BG=0 |
| 4 | |
| 5 | while [ $# -gt 0 ]; do |
| 6 | case $1 in |
| 7 | -bg|-background) |
| 8 | BG=1 |
| 9 | esac |
| 10 | shift |
| 11 | done |
| 12 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame^] | 13 | IP=$(ping -c 1 {{ controller_ip }} 2>/dev/null | grep PING | awk '{print $3}' | sed -e 's/[\(\)]//g') |
| 14 | while [ "$IP x" == " x" ]; do |
| 15 | echo "Waiting for controller to resolve ({{ controller_ip }}) ... sleeping 5s and will try again ..." |
| 16 | sleep 5 |
| 17 | IP=$(ping -c 1 {{ controller_ip }} 2>/dev/null | grep PING | awk '{print $3}' | sed -e 's/[\(\)]//g') |
| 18 | done |
| 19 | |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 20 | if [ $BG -eq 1 ]; then |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame^] | 21 | nohup brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller=$IP 2>&1 > connect.log & |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 22 | else |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame^] | 23 | brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller=$IP |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 24 | fi |