factor: factor2 variable is unused now, drop it
[oweals/busybox.git] / examples / udhcp / sample.renew
1 #!/bin/sh
2 # Sample udhcpc renew script
3
4 RESOLV_CONF="/etc/udhcpc/resolv.conf"
5
6 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
7 [ -n "$subnet" ] && NETMASK="netmask $subnet"
8
9 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
10
11 if [ -n "$router" ]
12 then
13         echo "deleting routers"
14         while /sbin/route del default gw 0.0.0.0 dev $interface
15         do :
16         done
17
18         metric=0
19         for i in $router
20         do
21                 if [ "$subnet" = "255.255.255.255" ]; then
22                         # special case for /32 subnets:
23                         # /32 instructs kernel to always use routing for all outgoing packets
24                         # (they can never be sent to local subnet - there is no local subnet for /32).
25                         # Used in datacenters, avoids the need for private ip-addresses between two hops.
26                         /sbin/ip route add $i dev $interface
27                 fi
28                 /sbin/route add default gw $i dev $interface metric $((metric++))
29         done
30 fi
31
32 # Only replace resolv.conf if we have at least one DNS server
33 if [ -n "$dns" ]
34 then
35         echo -n > $RESOLV_CONF
36         [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
37         for i in $dns
38         do
39                 echo adding dns $i
40                 echo nameserver $i >> $RESOLV_CONF
41         done
42 fi