#!/bin/bash
#
# VERSION=1
# CHANGES="initial version"

if [ -z "${1}" ]; then
	exit 1
fi

while sleep 10; do

	dhcp_en=$(/usr/fallback/beroconf get root lan-dhcp)
	if [ "${dhcp_en}" != "1" ] && [ "${dhcp_en}" != "yes" ]; then
		exit 0
	fi

	if [ -z "$(ps aux | grep udhcpc | grep -v grep)" ]; then
		/sbin/udhcpc -b -i ${1}
		continue
	fi
done
