ifcfg/write-ifcfg.sh: aggregate resolv.conf

The old code used /tmp/net.$netif.resolv.conf with $netif being randomly
chosen.

As it is not known which nameserver have which priority, just sort them
and deduplicate.
master
Harald Hoyer 2018-08-17 12:50:29 +02:00 committed by Harald Hoyer
parent 09132c732a
commit ee18dd2b88
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ depends() {

# called by dracut
install() {
inst_binary sort
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
}


View File

@ -286,7 +286,10 @@ echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
{
cp /tmp/net.* /run/initramfs/
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
for i in /tmp/net.*.resolv.conf; do
[ -f "$i" ] && cat "$i"
done | sort -u > /run/initramfs/state/etc/resolv.conf
[ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
} > /dev/null 2>&1