dnsmasq: Add match section support
[openwrt/staging/lynxis/omap.git] / package / network / services / dnsmasq / files / dnsmasq.init
index 4047768bba14449d06f3d1dd8dbc19842141d3c8..69c375c395728f8b0721fa53a38595772d61716f 100644 (file)
@@ -119,12 +119,12 @@ append_ipset() {
 }
 
 append_interface() {
-       local ifname=$(uci_get_state network "$1" ifname "$1")
+       network_get_device ifname "$1" || return
        xappend "--interface=$ifname"
 }
 
 append_notinterface() {
-       local ifname=$(uci_get_state network "$1" ifname "$1")
+       network_get_device ifname "$1" || return
        xappend "--except-interface=$ifname"
 }
 
@@ -351,6 +351,22 @@ dhcp_vendorclass_add() {
        dhcp_option_add "$cfg" "$networkid" "$force"
 }
 
+dhcp_match_add() {
+       local cfg="$1"
+
+       config_get networkid "$cfg" networkid
+       [ -n "$networkid" ] || return 0
+
+       config_get match "$cfg" match
+       [ -n "$match" ] || return 0
+
+       xappend "--dhcp-match=$networkid,$match"
+
+       config_get_bool force "$cfg" force 0
+
+       dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
 dhcp_host_add() {
        local cfg="$1"
 
@@ -643,6 +659,7 @@ start_service() {
        mkdir -p $(dirname $CONFIGFILE)
        mkdir -p /var/lib/misc
        touch /tmp/dhcp.leases
+       chown dnsmasq:dnsmasq /var/run/dnsmasq
 
        [ -f "$TIMESTAMPFILE" ] && rm -f "$TIMESTAMPFILE"
 
@@ -668,6 +685,7 @@ start_service() {
        config_foreach dhcp_circuitid_add circuitid
        config_foreach dhcp_remoteid_add remoteid
        config_foreach dhcp_subscrid_add subscrid
+       config_foreach dhcp_match_add match
        config_foreach dhcp_domain_add domain
        config_foreach dhcp_hostrecord_add hostrecord
        config_foreach dhcp_relay_add relay