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"
|
2014-01-15 20:04:58 +01:00
|
|
|
[ -e $RESOLV_CONF ] || touch $RESOLV_CONF
|
2002-11-15 03:55:17 +01:00
|
|
|
[ -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"
|
2014-01-16 08:58:33 +01:00
|
|
|
while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do
|
2002-11-15 03:55:17 +01:00
|
|
|
:
|
|
|
|
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
|
|
|
|
|
2016-03-31 09:34:43 +02:00
|
|
|
# prefer rfc3359 domain search list (option 119) if available
|
|
|
|
if [ -n "$search" ]; then
|
|
|
|
search_list=$search
|
|
|
|
elif [ -n "$domain" ]; then
|
|
|
|
search_list=$domain
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$search_list" ] &&
|
|
|
|
echo "search $search_list # $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
|
|
|
|
|
2014-06-17 07:21:47 +02:00
|
|
|
HOOK_DIR="$0.d"
|
|
|
|
for hook in "${HOOK_DIR}/"*; do
|
|
|
|
[ -f "${hook}" -a -x "${hook}" ] || continue
|
|
|
|
"${hook}" "${@}"
|
|
|
|
done
|
|
|
|
|
2002-11-15 03:55:17 +01:00
|
|
|
exit 0
|