fix(coreos-base/oem-vagrant): Add timeout for /etc/environment

The environment file will not be written if there are no public or
private networks defined since the configure_networks hook is never run.
Report an error after one minute to make this situation less confusing.
This commit is contained in:
Michael Marineau 2014-04-28 16:44:09 -04:00
parent 8b1ff15435
commit f16d776db2

View File

@ -7,7 +7,17 @@ if [ -z "$ENV" ]; then
exit 1 exit 1
fi fi
now=$(date +%s)
timeout=$(( now + 60 ))
# just block until cloudinit updates environment # just block until cloudinit updates environment
while ! grep -qs ^COREOS_PUBLIC_IPV4 "$ENV"; do while ! grep -qs ^COREOS_PUBLIC_IPV4 "$ENV"; do
if [[ $timeout -lt $(date +%s) ]]; then
echo "No network configuration provided by Vagrant!" >&2
echo "Using localhost, for default public and private IPs" >&2
echo "COREOS_PUBLIC_IPV4=127.0.0.1" >> "$ENV"
echo "COREOS_PRIVATE_IPV4=127.0.0.1" >> "$ENV"
exit
fi
sleep 0.1 sleep 0.1
done done