#!/bin/sh
exec 2>&1

# The Google services assert that the init is performing some
# sequencing.  Since runit provides no such facility, we will block
# all other services from launching here until we can talk to the
# metadata server.
while ! ping -c1 metadata.google.internal >/dev/null ; do
    sleep 5
done

# This is supposed to do all kinds of setup tasks to get the machine
# ready for the next phases of startup
google_instance_setup

# This script does a little more network setup to make sure all
# interfaces are up.  We don't really need it since dhcpcd will do
# this anyway, but its nice to use the provided one.
google_network_setup

# Both of those scripts are one-shots, so we drop privs and just sit
# here now to let the other scripts start.
exec chpst -u nobody:nogroup pause -b GCP-Guest-Initialization
