dnsmasq: rework network interface ignore
[openwrt/staging/jow.git] / package / network / services / dnsmasq / files / dnsmasq.init
index fd2ce3d2de0c1342e85dcee810250c0c08a50af4..c5e673029187555d1a81e8ec88fefb18b39c08d1 100755 (executable)
@@ -890,6 +890,12 @@ dnsmasq_start()
                xappend "--conf-file=${dnsmasqconffile}"
        }
 
+       config_get_bool boguspriv "$cfg" boguspriv 1
+       [ "$boguspriv" -gt 0 ] && {
+               xappend "--bogus-priv"
+               [ -r "$RFC6761FILE" ] && xappend "--conf-file=$RFC6761FILE"
+       }
+
        $PROG --version | grep -osqE "^Compile time options:.* DHCPv6( |$)" && DHCPv6CAPABLE=1 || DHCPv6CAPABLE=0
 
 
@@ -952,7 +958,25 @@ dnsmasq_start()
        config_get tftp_root "$cfg" "tftp_root"
        [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
        append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
-       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+
+       config_get bind "$cfg" "bind"
+       case "$bind" in
+               dynamic|interfaces)
+                       xappend "--bind-$bind"
+                       ;;
+               "")
+                       # for compatibility reasons
+                       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+                       ;;
+       esac
+
+       config_get dnsfilter "$cfg" "dnsfilter"
+       case "$dnsfilter" in
+               A|AAAA)
+                       xappend "--filter-$dnsfilter"
+                       ;;
+       esac
+
        append_bool "$cfg" fqdn "--dhcp-fqdn"
        append_bool "$cfg" proxydnssec "--proxy-dnssec"
        append_bool "$cfg" localservice "--local-service"
@@ -1000,8 +1024,8 @@ dnsmasq_start()
                xappend "--addn-hosts=$HOSTFILE"
                append EXTRA_MOUNT "$HOSTFILE"
        else
-               xappend "--addn-hosts=$HOSTFILE_DIR"
-               append EXTRA_MOUNT "$HOSTFILE_DIR"
+               xappend "--addn-hosts=$(dirname $HOSTFILE)"
+               append EXTRA_MOUNT "$(dirname $HOSTFILE)"
        fi
        config_list_foreach "$cfg" "addnhosts" append_addnhosts
        config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
@@ -1105,7 +1129,6 @@ dnsmasq_start()
 
        xappend "--dhcp-broadcast=tag:needs-broadcast"
 
-
        config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d"
        xappend "--conf-dir=$dnsmasqconfdir"
        dnsmasqconfdir="${dnsmasqconfdir%%,*}"
@@ -1147,11 +1170,6 @@ dnsmasq_start()
        config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg"
        echo >> $CONFIGFILE_TMP
 
-       config_get_bool boguspriv "$cfg" boguspriv 1
-       [ "$boguspriv" -gt 0 ] && {
-               xappend "--bogus-priv"
-               [ -r "$RFC6761FILE" ] && xappend "--conf-file=$RFC6761FILE"
-       }
 
        if [ "$DNSMASQ_DHCP_VER" -gt 4 ] ; then
                # Enable RA feature for when/if it is constructed,
@@ -1235,10 +1253,11 @@ dnsmasq_stop()
 
 add_interface_trigger()
 {
-       local interface ignore
+       local interface ifname ignore
 
        config_get interface "$1" interface
        config_get_bool ignore "$1" ignore 0
+       network_get_device ifname "$interface" || ignore=0
 
        [ -n "$interface" ] && [ $ignore -eq 0 ] && procd_add_interface_trigger "interface.*" "$interface" /etc/init.d/dnsmasq reload
 }