1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
10 while [ -n "$ip" ]; do
13 res
="$(($res + $part))"
14 [ "${ip%.*}" != "$ip" ] && ip
="${ip#*.}" || ip
=
22 config_get net
"$cfg" interface
23 [ -n "$net" ] ||
return 0
25 config_get ifname
"$net" ifname
26 [ -n "$ifname" ] ||
return 0
28 config_get_bool ignore
"$cfg" ignore
29 [ "$ignore" -gt 0 ] && {
30 append args
"-I $ifname"
34 config_get proto
"$net" proto
35 [ static
= "$proto" ] ||
return 0
37 config_get ipaddr
"$net" ipaddr
38 config_get netmask
"$net" netmask
40 # check for an already active dhcp server on the interface, unless 'force' is set
41 config_get_bool force
"$cfg" force
0
42 [ "$force" -gt 0 ] ||
{
43 udhcpc
-n -q -R -s /bin
/true
-t 1 -i $ifname >&- && return 0
46 config_get start
"$cfg" start
47 config_get end
"$cfg" end
48 config_get leasetime
"$cfg" leasetime
49 config_get options
"$cfg" options
51 leasetime
="${leasetime:-12h}"
52 start
="$(dhcp_calc "${start:-100}")"
53 end
="$((${end:-150} + 1))"
54 eval "$(ipcalc.sh $ipaddr $netmask $start $end)"
55 append args
"-F $START,$END,$NETMASK,$leasetime${options:+ $options}"
64 config_foreach dhcp_add dhcp
67 rm -f /tmp
/resolv.conf
68 cat > /tmp
/resolv.conf
<<EOF