From 5c4be3e15876f3a1e3fd8a6a4737decf18914161 Mon Sep 17 00:00:00 2001 From: Ronelle Landy Date: Fri, 12 Feb 2021 13:41:17 -0500 Subject: [PATCH] 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 --- elements/remove-resolvconf/cleanup.d/90-remove-resolvconf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elements/remove-resolvconf/cleanup.d/90-remove-resolvconf b/elements/remove-resolvconf/cleanup.d/90-remove-resolvconf index 66278ac9..af9c9732 100755 --- a/elements/remove-resolvconf/cleanup.d/90-remove-resolvconf +++ b/elements/remove-resolvconf/cleanup.d/90-remove-resolvconf @@ -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