source: freewrt/package/dnsmasq/files/dnsmasq.init@ 9df7618

freewrt_1_0 freewrt_2_0
Last change on this file since 9df7618 was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.4 KB
Line 
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
11args=""
12iface=lan
13eval "ifname=\${${iface}_ifname}"
14
15dhcp_enable="${dhcp_enable:-1}"
16dhcp_start="${dhcp_start:-100}"
17dhcp_num="${dhcp_num:-50}"
18dhcp_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
Note: See TracBrowser for help on using the repository browser.