fix MODULE_PARM removal in 2.6.17.
[openwrt.git] / package / dnsmasq / files / dnsmasq.init
1 #!/bin/sh
2 . /etc/config/network
3
4 # The following is to automatically configure the DHCP settings
5 # based on config settings. Feel free to replace all this crap
6 # with a simple "dnsmasq" and manage everything via the
7 # /etc/dnsmasq.conf config file
8
9 [ -f /etc/dnsmasq.conf ] || exit
10
11 args=""
12 iface=lan
13 eval "ifname=\${${iface}_ifname}"
14
15 dhcp_enable="${dhcp_enable:-1}"
16 dhcp_start="${dhcp_start:-100}"
17 dhcp_num="${dhcp_num:-50}"
18 dhcp_lease="${dhcp_lease:-12h}"
19
20 # if dhcp_enable is unset and there is a dhcp server on the network already, default to dhcp_enable=0
21 [ -z "$dhcp_enable" ] && udhcpc -n -q -R -s /bin/true -i $ifname >&- && dhcp_enable="${dhcp_enable:-0}"
22
23 # dhcp_enable=0 disables the dhcp server
24 (
25 [ -z "$dhcp_enable" -o "$dhcp_enable" -eq 1 ] && {
26 # no existing DHCP server?
27
28 # calculate settings
29 eval "ipaddr=\${${iface}_ipaddr}"
30 eval "netmask=\${${iface}_netmask}"
31 eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150})
32
33 # and pass the args via config parser defines
34 echo "@define dhcp_enable 1"
35 echo "@define netmask $NETMASK"
36 echo "@define start $START"
37 echo "@define end $END"
38 echo "@define lease ${dhcp_lease:-12h}"
39 }
40
41 # ignore requests from wan interface
42 [ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname"
43
44 cat /etc/dnsmasq.conf
45 ) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0
This page took 0.04062 seconds and 5 git commands to generate.