Check that etc/resolv.conf.ORIG exists before edit

In RHEL 8.4, /etc/resolv.conf is not present by default.
As such, removing the nameservers will fail because
etc/resolv.conf.ORIG never gets created.

This patch makes the nameserver edit only if the
etc/resolv.conf.ORIG file exists.

Change-Id: I2178996d899ffe43e11bfeb512e4fcaa941b8410
This commit is contained in:
Ronelle Landy 2021-02-12 13:41:17 -05:00
parent ad31a40211
commit 5c4be3e158

View File

@ -11,4 +11,6 @@ set -o pipefail
# NOTE: This relies on the fact the DIB copies the original resolv.conf and
# during the finalise_base function in img-functions (in DIB) copies the old
# one back in place after the build process completes.
sudo sed -i '/nameserver/d' $TARGET_ROOT/etc/resolv.conf.ORIG
if [ -f $TARGET_ROOT/etc/resolv.conf.ORIG ] ; then
sudo sed -i '/nameserver/d' $TARGET_ROOT/etc/resolv.conf.ORIG
fi