]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf"
authorXunlei Pang <xlpang@redhat.com>
Tue, 26 Apr 2016 10:05:11 +0000 (18:05 +0800)
committerHarald Hoyer <harald@redhat.com>
Wed, 29 Jun 2016 15:27:36 +0000 (17:27 +0200)
Users can pass the DNS information throught "nameserver=" cmdline,
there maybe duplicated inputs.

"/etc/resolv.conf" have some restrictions on the number of DNS items
effective, so make sure that this file contains no duplicated items.

We achieve this by simply making the file have no duplicated lines.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
(cherry picked from commit 4fa5c235a76c085f5958002826436ed9c40e5034)

modules.d/40network/module-setup.sh
modules.d/40network/net-lib.sh

index 75ce622435083fba7b5bc6d503e35acb68756f07..de353674382b8a9aa8dc8054b9d3ecd055aa59ec 100755 (executable)
@@ -69,7 +69,7 @@ installkernel() {
 
 install() {
     local _arch _i _dir
-    inst_multiple ip arping dhclient sed
+    inst_multiple ip arping dhclient sed awk
     inst_multiple -o ping ping6
     inst_multiple -o brctl
     inst_multiple -o teamd teamdctl teamnl
index 92154cc6a515d7b0d8f8a8d6314e5958ef065259..e6942a55d8043984e373a83f01385f302e88a1e7 100755 (executable)
@@ -121,7 +121,7 @@ setup_net() {
     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
     # set up resolv.conf
     [ -e /tmp/net.$netif.resolv.conf ] && \
-        cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
+        awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
     [ -e /tmp/net.$netif.gw ]            && . /tmp/net.$netif.gw
 
     # add static route