#!/bin/sh
# $Revision$ $Author$ $Date$
#switch to DHCP
INTERFACES_TO_SWITCH=interfaces.dhcp

cd /etc/network/
echo -n "Switching interface to DHCP... "

#take down ethx
myif=`ifconfig | grep ^eth | sed "s/\(eth[0-9]*\).*/\1/"`
if [ ! -z "$myif" ]
then
	ifdown $myif
	echo -n "$myif down "
fi

rm -f interfaces.old
mv interfaces interfaces.old
cat interfaces.old | sed "s/static/dhcp/; s/^\( *\)address/#\1address/; s/^\( *\)netmask/#\1netmask/;  s/^\( *\)gateway/#\1gateway/" > interfaces

echo -n "interfaces_modified "

#now bring it back up
if [ ! -z "$myif" ]
then
	ifup $myif
	echo -n "$myif up "
fi

echo "Done!"

