]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network: remove awk call and replace it with a shell function
authorHarald Hoyer <harald@redhat.com>
Tue, 7 Jun 2016 09:11:58 +0000 (11:11 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 7 Jun 2016 09:15:07 +0000 (11:15 +0200)
changes commit 4fa5c235a76c085f5958002826436ed9c40e5034

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

index 4496bfe6c129e2d09172e4f542c8f21c254429da..146dbea0583b02377eea2576112e75f0c7167638 100755 (executable)
@@ -37,6 +37,16 @@ str_starts() { [ "${1#"$2"*}" != "$1" ]; }
 # returns OK if $1 contains literal string $2 at the end, and isn't empty
 str_ends() { [ "${1%*"$2"}" != "$1" ]; }
 
+uniq_lines() {
+    local -A lines
+    while read -r line; do
+        if ! [[ ${lines[$line]} ]]; then
+            echo "$line"
+            lines[$line]=1
+        fi
+    done
+}
+
 # find a binary.  If we were not passed the full path directly,
 # search in the usual places to find the binary.
 find_binary() {
index 53b4b60b31cd48c91ea3f7ebb59d6063aca38ecb..4bf93cc6d775a2166f2f2a092016442741fcfca1 100755 (executable)
@@ -23,7 +23,7 @@ installkernel() {
 # called by dracut
 install() {
     local _arch _i _dir
-    inst_multiple ip arping dhclient sed awk
+    inst_multiple ip arping dhclient sed
     inst_multiple -o ping ping6
     inst_multiple -o brctl
     inst_multiple -o teamd teamdctl teamnl
index 005ad1bb82b1438f73a709bf616a0067cfbd1090..4fd274e8decebff07a60149509d983164d24d1c8 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 ] && \
-        awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
+        uniq_lines < /tmp/net.$netif.resolv.conf > /etc/resolv.conf
     [ -e /tmp/net.$netif.gw ]            && . /tmp/net.$netif.gw
 
     # add static route