William A. Kennington III | bef990f | 2022-02-08 16:50:30 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2022 Google LLC |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # Wait until a well known service is network available |
| 17 | echo "Waiting for network reachability" >&2 |
| 18 | while ! ping -c 1 -W 1 2001:4860:4860::8888 >/dev/null 2>&1; do |
| 19 | sleep 1 |
| 20 | done |
| 21 | wait_min=5 |
| 22 | echo "Network is reachable, waiting $wait_min minutes" >&2 |
| 23 | # Wait 5 minutes for any potential DHCP that hasn't landed yet |
| 24 | sleep $((60 * wait_min)) |
| 25 | # If the DHCP configuration process is running, wait for it to finish |
| 26 | if pid="$(cat /run/gbmc-br-dhcp.pid 2>/dev/null)"; then |
| 27 | echo "DHCP still running ($pid), waiting" >&2 |
| 28 | wait "$pid" |
| 29 | fi |
| 30 | echo "Stopping DHCP processing" >&2 |
| 31 | systemctl stop --no-block gbmc-br-dhcp |