#!/bin/sh
# Sets up the dhcp part of dnsmasq
-. /etc/functions.sh
+. /lib/functions.sh
. $dir/functions.sh
net="$1"
+vap="$(uci -q get meshwizard.netconfig.${net}_vap)"
handle_dnsmasq() {
config_get interface "$1" interface
if [ "$interface" == "${netrenamed}dhcp" ]; then
- if [ "$cleanup" == 1 ]; then
- section_cleanup dhcp.$1
- else
- if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
- section_rename dhcp $1 ${netrenamed}dhcp
- fi
- fi
- fi
+ if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
+ section_rename dhcp $1 ${netrenamed}dhcp
+ fi
+ fi
}
config_load dhcp
config_foreach handle_dnsmasq dhcp
-uci batch << EOF
-set dhcp.${netrenamed}dhcp="dhcp"
-set dhcp.${netrenamed}dhcp.leasetime="$dhcp_leasetime"
-set dhcp.${netrenamed}dhcp.force="$dhcp_force"
-set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
-EOF
+[ "$net" == "lan" ] && uci -q delete dhcp.lan
+
+if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
+ uci batch <<- EOF
+ set dhcp.${netrenamed}dhcp="dhcp"
+ set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
+ EOF
+ set_defaults "dhcp_" dhcp.${netrenamed}dhcp
+fi
+
+ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
+if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
+ uci batch <<- EOF
+ set dhcp.${netrenamed}ahdhcp="dhcp"
+ set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
+ EOF
+fi
+set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
uci_commitverbose "Setup DHCP for $netrenamed" dhcp
+