#!/bin/sh

if [ -e /etc/config/udhcpd.ifaces ]; then
	. /etc/config/udhcpd.ifaces
else
	IFACES=ixp0
fi

case "$1" in
	start)
	echo -n "Starting udhcpd on interface(s): "
	for ifc in ${IFACES}; do
		/sbin/udhcpd /etc/config/udhcpd.conf.${ifc}
	done
	echo
	;;

	stop)
	echo -n "Stoping udhcp on interface(s): "
	for ifc in ${IFACES}; do
		kill `cat /var/run/udhcpd.${ifc}`
	done
	echo

	;;
	*)
	echo "Usage: /usr/etc/init.d/udhcpd (start|stop)"
	exit 1
	;;
esac
