#!/bin/sh
##
## config_net: this script configures the interface according to the
## environment variable 'netconfig'
##
hwclock --hctosys
# defaults
DHCLIENT=dhclient

. /etc/config_net.conf

# try dhcp?
NETCONFIG=`cat /jffs2/etc/dhcp/netconfig`

if [ "$NETCONFIG" = "1" ]; then

    # run dhclient
    $DHCLIENT -1 $NO_DAEMON $QUIET $DHCLIENT_CONF $DHCLIENT_SCRIPT $IF

    if [ $? -eq 0 ]; then
	echo "DHCP_OK" > /tmpfs/tmp/dhcp.log
	echo "Received new ip via dhcp."
	exit 0
    fi
fi

# configure with default values
echo "No dhcp available"
echo "No_DHCP" > tmpfs/tmp/dhcp.log
exit 0
