]> git.ipfire.org Git - people/stevee/network.git/commitdiff
DNS: Add static search domains.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Oct 2012 15:29:18 +0000 (15:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Oct 2012 15:29:18 +0000 (15:29 +0000)
functions.dns
functions.list

index 33f80201729201d0122bb8641be91eb70c30a63a..5f964ba52c5e69458446b6273536a668cc99b9ea 100644 (file)
@@ -28,6 +28,9 @@ NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_USE_LOCAL_RESOLVER
 DNS_RANDOMIZE=false
 NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_RANDOMIZE"
 
+DNS_SEARCH_DOMAINS=""
+NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_SEARCH_DOMAINS"
+
 # Set this option to true if the DNS servers should be advertised by
 # radvd.
 DNS_ADVERTISE_SERVERS="true"
@@ -126,7 +129,10 @@ function dns_generate_resolvconf() {
                print "option rotate\n" >> ${file}
        fi
 
-       # XXX Add search domain.
+       # Add search domains.
+       local search_domains="$(unquote ${DNS_SEARCH_DOMAINS})"
+
+       # Get search domains from DHCP clients, etc.
        local proto
        local zone
        local domainname
@@ -134,9 +140,17 @@ function dns_generate_resolvconf() {
                for proto in ${IP_SUPPORTED_PROTOCOLS}; do
                        domainname=$(routing_db_get ${zone} ${proto} domain-name)
                        if [ -n "${domainname}" ]; then
-                               print "search ${domainname}"
+                               list_append search_domains "${domainname}"
                        fi
                done
+       done
+
+       # Sort out duplicate entries.
+       search_domains=$(list_unique ${search_domains})
+
+       # Write search domains to file.
+       for domainname in ${search_domains}; do
+               print "search ${domainname}"
        done >> ${file}
 
        # Add the local resolver as the first DNS server if enabled.
index fa22a6668f59b4782ebf4a7acab55e3409756047..c33d4db687d37b3a53d03811d8e56f1f4cb5d7f1 100644 (file)
@@ -59,6 +59,17 @@ function list_sort() {
        print
 }
 
+function list_unique() {
+       local items item
+       for item in $@; do
+               # Check if the item has already been processed.
+               list_match "${item}" ${items} && continue
+
+               list_append items "${item}"
+               print "${item}"
+       done
+}
+
 function list_match() {
        local match=${1}
        shift