#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 Samuel Tyler <samuel@samuelt.me>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
ensure_network_ready
# Ensure network accessible
timeout=120
while ! curl example.com >/dev/null 2>&1; do
    sleep 1
    # shellcheck disable=SC2219
    let timeout--
    if [ "${timeout}" -le 0 ]; then
        echo "Timeout reached for internet to become accessible"
        false
    fi
done

sed -i '/^NETWORK_READY=/d' /steps/env
echo 'NETWORK_READY=True' >> /steps/env
