#!/bin/sh

[ "$WRP_CFG" ] || . /etc/wrp.cfg
int=""
for i in "$LOCAL_INTERFACES" "$EXTERN_INTERFACES"; do
    rng=`. /etc/wrp.cfg; $i; echo "$DHCP_RANGE"`
    [ "$rng" ] && int=$i && break
done

if [ -z "$int" ]; then
    echo "No DHCP ranges defined."
    exit
fi

echo -n "Configuring DHCP for $int ";

$int; # source interface definitions

# Write /etc/dhcpd.conf
#
cat > /etc/dhcpd.conf <<End
subnet $NETMASK 
router $IP_ADDR 
End

# Write /etc/dhcpd.iplist
#
/sbin/makeiprange /etc/dhcpd.iplist $DHCP_RANGE

echo "."

