fix missing update for include() api change (#815)
[openwrt-10.03/.git] / package / dnsmasq / files / dnsmasq.init
index 17ef43c3d5f1c1884786f2c6271b5005a58fd808..cbbee02ce7b90df97edeee3eb725b80b6ce1817f 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/sh
-. /etc/config/network
+. /etc/functions.sh
+include /lib/network
+scan_interfaces
 
 # The following is to automatically configure the DHCP settings
 # based on config settings. Feel free to replace all this crap
 
 args=""
 iface=lan
-eval "ifname=\${${iface}_ifname}"
+config_get ifname "$iface" ifname
+config_get proto "$iface" proto
 
-dhcp_enable="${dhcp_enable:-1}"
+[ "$proto" = static ] && dhcp_enable="${dhcp_enable:-1}"
 dhcp_start="${dhcp_start:-100}"
 dhcp_num="${dhcp_num:-50}"
 dhcp_lease="${dhcp_lease:-12h}"
@@ -26,12 +29,12 @@ dhcp_lease="${dhcp_lease:-12h}"
                # no existing DHCP server?
 
                # calculate settings
-               eval "ipaddr=\${${iface}_ipaddr}"
-               eval "netmask=\${${iface}_netmask}"
+               config_get ipaddr "$iface" ipaddr
+               config_get netmask "$iface" netmask
                eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150})
                
                # and pass the args via config parser defines
-               echo "@define dhcp_enable 1"
+               echo "${dhcp_enable:+@define dhcp_enable 1}"
                echo "@define netmask $NETMASK"
                echo "@define start $START"
                echo "@define end $END"
@@ -39,6 +42,8 @@ dhcp_lease="${dhcp_lease:-12h}"
        }
 
        # ignore requests from wan interface
+       config_get wan_proto wan proto
+       config_get wan_ifname wan ifname
        [ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname"
 
        cat /etc/dnsmasq.conf