update example udhcpc script

This commit is contained in:
Denis Vlasenko 2009-04-16 20:04:09 +00:00
parent fa4ca7889e
commit ea4f0847c3

View File

@ -5,35 +5,42 @@
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf" RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" NETMASK=""
[ -n "$subnet" ] && NETMASK="netmask $subnet" [ -n "$subnet" ] && NETMASK="netmask $subnet"
BROADCAST="broadcast +"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
case "$1" in case "$1" in
deconfig) deconfig)
/sbin/ifconfig $interface 0.0.0.0 echo "Setting IP address 0.0.0.0 on $interface"
ifconfig $interface 0.0.0.0
;; ;;
renew|bound) renew|bound)
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK echo "Setting IP address $ip on $interface"
ifconfig $interface $ip $NETMASK $BROADCAST
if [ -n "$router" ] ; then if [ -n "$router" ] ; then
echo "deleting routers" echo "Deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do while route del default gw 0.0.0.0 dev $interface ; do
: :
done done
metric=0 metric=0
for i in $router ; do for i in $router ; do
echo "Adding router $i"
route add default gw $i dev $interface metric $((metric++)) route add default gw $i dev $interface metric $((metric++))
done done
fi fi
echo -n > $RESOLV_CONF echo "Recreating $RESOLV_CONF"
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF echo -n > $RESOLV_CONF-$$
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF-$$
for i in $dns ; do for i in $dns ; do
echo adding dns $i echo " Adding DNS server $i"
echo nameserver $i >> $RESOLV_CONF echo nameserver $i >> $RESOLV_CONF-$$
done done
mv $RESOLV_CONF-$$ $RESOLV_CONF
;; ;;
esac esac