2002-11-15 03:55:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
|
|
|
|
|
|
|
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
|
|
|
|
|
|
|
RESOLV_CONF="/etc/resolv.conf"
|
|
|
|
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
|
|
|
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
deconfig)
|
2013-06-26 14:29:19 +02:00
|
|
|
/sbin/ifconfig $interface up
|
|
|
|
/sbin/ifconfig $interface 0.0.0.0
|
|
|
|
|
2013-06-26 15:01:46 +02:00
|
|
|
# drop info from this interface
|
|
|
|
# resolv.conf may be a symlink to /tmp/, so take care
|
|
|
|
TMPFILE=$(mktemp)
|
|
|
|
grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
|
|
|
|
cat $TMPFILE > $RESOLV_CONF
|
|
|
|
rm -f $TMPFILE
|
|
|
|
|
2013-06-26 14:22:13 +02:00
|
|
|
if [ -x /usr/sbin/avahi-autoipd ]; then
|
|
|
|
/usr/sbin/avahi-autoipd -k $interface
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
leasefail|nak)
|
|
|
|
if [ -x /usr/sbin/avahi-autoipd ]; then
|
|
|
|
/usr/sbin/avahi-autoipd -wD $interface --no-chroot
|
|
|
|
fi
|
2002-11-15 03:55:17 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
renew|bound)
|
2013-06-26 14:22:13 +02:00
|
|
|
if [ -x /usr/sbin/avahi-autoipd ]; then
|
|
|
|
/usr/sbin/avahi-autoipd -k $interface
|
|
|
|
fi
|
2002-11-15 03:55:17 +01:00
|
|
|
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
|
|
|
|
|
|
|
if [ -n "$router" ] ; then
|
|
|
|
echo "deleting routers"
|
|
|
|
while route del default gw 0.0.0.0 dev $interface ; do
|
|
|
|
:
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in $router ; do
|
|
|
|
route add default gw $i dev $interface
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-06-26 15:01:46 +02:00
|
|
|
# drop info from this interface
|
|
|
|
# resolv.conf may be a symlink to /tmp/, so take care
|
|
|
|
TMPFILE=$(mktemp)
|
|
|
|
grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
|
|
|
|
cat $TMPFILE > $RESOLV_CONF
|
|
|
|
rm -f $TMPFILE
|
|
|
|
|
|
|
|
[ -n "$domain" ] && echo "search $domain # $interface" >> $RESOLV_CONF
|
2002-11-15 03:55:17 +01:00
|
|
|
for i in $dns ; do
|
|
|
|
echo adding dns $i
|
2013-06-26 15:01:46 +02:00
|
|
|
echo "nameserver $i # $interface" >> $RESOLV_CONF
|
2002-11-15 03:55:17 +01:00
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|