network: remove awk call and replace it with a shell function

changes commit 4fa5c235a7
master
Harald Hoyer 2016-06-07 11:11:58 +02:00
parent f3355208f9
commit 71867b665c
3 changed files with 12 additions and 2 deletions

View File

@ -37,6 +37,16 @@ str_starts() { [ "${1#"$2"*}" != "$1" ]; }
# returns OK if $1 contains literal string $2 at the end, and isn't empty # returns OK if $1 contains literal string $2 at the end, and isn't empty
str_ends() { [ "${1%*"$2"}" != "$1" ]; } 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, # find a binary. If we were not passed the full path directly,
# search in the usual places to find the binary. # search in the usual places to find the binary.
find_binary() { find_binary() {

View File

@ -23,7 +23,7 @@ installkernel() {
# called by dracut # called by dracut
install() { install() {
local _arch _i _dir 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 ping ping6
inst_multiple -o brctl inst_multiple -o brctl
inst_multiple -o teamd teamdctl teamnl inst_multiple -o teamd teamdctl teamnl

View File

@ -120,7 +120,7 @@ setup_net() {
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# set up resolv.conf # set up resolv.conf
[ -e /tmp/net.$netif.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 [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw


# add static route # add static route