contrib/package: /etc/functions.sh => /lib/functions.sh
[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
9 handle_dnsmasq() {
10         config_get interface "$1" interface
11         if [ "$interface" == "${netrenamed}dhcp" ]; then
12                 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
13                         section_rename dhcp $1 ${netrenamed}dhcp
14                 fi
15         fi
16 }
17 config_load dhcp
18 config_foreach handle_dnsmasq dhcp
19
20 [ "$net" == "lan" ] && uci -q delete dhcp.lan
21
22 uci batch << EOF
23         set dhcp.${netrenamed}dhcp="dhcp"
24         set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
25 EOF
26
27 set_defaults "dhcp_" dhcp.${netrenamed}dhcp
28
29 uci_commitverbose "Setup DHCP for $netrenamed" dhcp
30