]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" 137/head
authorXunlei Pang <xlpang@redhat.com>
Tue, 26 Apr 2016 10:05:11 +0000 (18:05 +0800)
committerHarald Hoyer <harald@redhat.com>
Tue, 26 Apr 2016 11:03:30 +0000 (13:03 +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>
modules.d/40network/module-setup.sh
modules.d/40network/net-lib.sh

index 4bf93cc6d775a2166f2f2a092016442741fcfca1..53b4b60b31cd48c91ea3f7ebb59d6063aca38ecb 100755 (executable)
@@ -23,7 +23,7 @@ installkernel() {
 # called by dracut
 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 31f1a5672b14142dbbd300bde22d854c75f74ced..005ad1bb82b1438f73a709bf616a0067cfbd1090 100755 (executable)
@@ -120,7 +120,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