initial commit
[udhcp] / samples / sample.bound
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 "Resetting default routes"
26         for i in `/sbin/route -n | grep ^default.*$interface`
27         do
28                 route del default gw 0.0.0.0 dev $interface
29         done
30
31         for i in $router
32         do
33                 /sbin/route add default gw $i dev $interface
34         done
35 fi
36
37 # Update resolver configuration file
38 R=""
39 [ -n "$domain" ] && R="domain $domain
40 "
41 for i in $dns
42 do
43         echo adding dns $i
44         R="${R}nameserver $i
45 "
46 done
47
48 if [ -x /sbin/resolvconf ] ; then
49         echo -n "$R" | resolvconf -a "${interface}.udhcpc"
50 else
51         echo -n "$R" > "$RESOLV_CONF"
52 fi
53