contrib/meshwizard: Also setup a dhcp server on the adhoc interface if VAP is used...
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_dhcp.sh
1 #!/bin/sh
2 # Sets up the dhcp part of dnsmasq
3
4 . /lib/functions.sh
5 . $dir/functions.sh
6
7 net="$1"
8 vap="$(uci -q get meshwizard.netconfig.${net}_vap)"
9
10 handle_dnsmasq() {
11         config_get interface "$1" interface
12         if [ "$interface" == "${netrenamed}dhcp" ]; then
13                 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
14                         section_rename dhcp $1 ${netrenamed}dhcp
15                 fi
16         fi
17 }
18 config_load dhcp
19 config_foreach handle_dnsmasq dhcp
20
21 [ "$net" == "lan" ] && uci -q delete dhcp.lan
22
23 if [ "$vap" == 1 ]; then
24         uci batch <<- EOF
25                 set dhcp.${netrenamed}dhcp="dhcp"
26                 set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
27         EOF
28         set_defaults "dhcp_" dhcp.${netrenamed}dhcp
29 fi
30
31 uci batch << EOF
32         set dhcp.${netrenamed}ahdhcp="dhcp"
33         set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
34 EOF
35
36 set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
37
38 uci_commitverbose "Setup DHCP for $netrenamed" dhcp
39
40