#!/bin/sh
# Basic TCP/IP
# Recreate a handful of /etc files
#
. /boot.conf
test "$LOG_START" && echo "<*> Executing '$0 $*'"

if test "${GATEWAY:0:4}" = "DHCP"; then
    unset GATEWAY
fi
if test "${DNS:0:4}" = "DHCP"; then
    DNS="127.0.0.1"
fi

# If there is a gateway defined or obtained by DHCP, then set it up:
if test "$GATEWAY"; then
    test "$LOG_STAGE" && echo "* Default route thru gateway $GATEWAY"
    ip r a 0/0 via $GATEWAY \
    || echo "! route add default gw failure"
fi

test "$LOG_STAGE" && echo "* Recreating some /etc/* files reflecting current configuration:"
echo -n " "
for i in /etc/rc.d/etc/*; do
    n=`basename $i`
    echo -n " $n"
    (. $i) >/etc/$n
done
echo

exit 0
