#!/bin/bash
# DHCP client container startup
# Gets network config (DNS server, search domain) from DHCP
set -e

echo "DHCP client starting..."

# Run dhclient - it will get a lease from dnsmasq on the greenwave sim
# The lease file at /var/lib/dhcp/dhclient.leases records what was offered
mkdir -p /var/lib/dhcp
dhclient -v eth0 2>&1 || true

echo "DHCP client ready: $(hostname)"
echo "Lease info:"
cat /var/lib/dhcp/dhclient.leases 2>/dev/null | head -20

sleep infinity
