2 # udhcpc script edited by Tim Riker <Tim@Rikers.org>
4 RESOLV_CONF="/etc/resolv.conf"
6 [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
9 [ -n "$subnet" ] && NETMASK="netmask $subnet"
10 BROADCAST="broadcast +"
11 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
15 echo "Setting IP address 0.0.0.0 on $interface"
16 ifconfig $interface 0.0.0.0
20 echo "Setting IP address $ip on $interface"
21 ifconfig $interface $ip $NETMASK $BROADCAST
23 if [ -n "$router" ] ; then
24 echo "Deleting routers"
25 while route del default gw 0.0.0.0 dev $interface ; do
31 echo "Adding router $i"
32 route add default gw $i dev $interface metric $metric
37 echo "Recreating $RESOLV_CONF"
38 # If the file is a symlink somewhere (like /etc/resolv.conf
39 # pointing to /run/resolv.conf), make sure things work.
40 realconf=$(readlink -f "$RESOLV_CONF" 2>/dev/null || echo "$RESOLV_CONF")
41 tmpfile="$realconf-$$"
43 [ -n "$domain" ] && echo "search $domain" >> "$tmpfile"
45 echo " Adding DNS server $i"
46 echo "nameserver $i" >> "$tmpfile"
48 mv "$tmpfile" "$realconf"