I'm working on a linux gadget.
I want it to get DHCP if I plug in the network cable after it has booted up
already or if the network cable unplugged and replugged.
One solution is to run a script such as this (which works, btw):
#!/bin/bash
NET_STATUS='different'
while true
do
NEW_NET_STATUS=`ifconfig | grep RUNNING | grep -v LOOPBACK`
if [ "${NEW_NET_STATUS}" = "${NET_STATUS}" ]
then
echo "no change"
sleep 1
continue
fi
NET_STATUS=${NEW_NET_STATUS}
if [ "${NET_STATUS}" ]
then
echo "cable plugged in"
else
echo "cable unplugged"
fi
sleep 1
done
However, I've got a feeling deep down in my little toe that tells me that
there's a better way to deal with hotplug events for the ethernet cable.
Do any of you know what way that is?
Question also on SuperUser:
http://superuser.com/questions/332968/how-to-configure-eth0-to-retry-dhclient-when-unplugged-and-replugged
AJ ONeal
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/