initial commit
[udhcp] / samples / sample.renew
1 #!/bin/sh
2 # Sample udhcpc bound/renew script
3
4 # Uncomment this to allow dhcpcd to set hostname of the host to the
5 # hostname option supplied by DHCP server.
6 #SET_HOSTNAME='yes'
7
8 RESOLV_CONF="/etc/resolv.conf"
9
10 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
11 [ -n "$subnet" ] && NETMASK="netmask $subnet"
12
13 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
14
15 if [ -n "$hostname" -a -n "$SET_HOSTNAME" ]
16 then
17         local current_hostname=$(hostname)
18         if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
19           hostname "$hostname"
20         fi
21 fi
22
23 if [ -n "$router" ]
24 then
25         echo "deleting routers"
26         while /sbin/route del default gw 0.0.0.0 dev $interface
27         do :
28         done
29
30         for i in $router
31         do
32                 /sbin/route add default gw $i dev $interface
33         done
34 fi
35
36 # Update resolver configuration file
37 R=""
38 [ -n "$domain" ] && R="domain $domain
39 "
40 for i in $dns
41 do
42         echo adding dns $i
43         R="${R}nameserver $i
44 "
45 done
46
47 if [ -x /sbin/resolvconf ] ; then
48         echo -n "$R" | resolvconf -a "${interface}.udhcpc"
49 else
50         echo -n "$R" > "$RESOLV_CONF"
51 fi
52