blob: 29fbbdeda5aa638b507f81d4b126910a521fa0e6 [file] [log] [blame]
William A. Kennington IIIbef990f2022-02-08 16:50:30 -08001#!/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
17echo "Waiting for network reachability" >&2
18while ! ping -c 1 -W 1 2001:4860:4860::8888 >/dev/null 2>&1; do
19 sleep 1
20done
21wait_min=5
22echo "Network is reachable, waiting $wait_min minutes" >&2
23# Wait 5 minutes for any potential DHCP that hasn't landed yet
24sleep $((60 * wait_min))
25# If the DHCP configuration process is running, wait for it to finish
26if pid="$(cat /run/gbmc-br-dhcp.pid 2>/dev/null)"; then
27 echo "DHCP still running ($pid), waiting" >&2
28 wait "$pid"
29fi
30echo "Stopping DHCP processing" >&2
31systemctl stop --no-block gbmc-br-dhcp