Browse Source

Merge "Copy resolv.conf handling from diskimage-builder"

master
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
04eb76f307
1 changed files with 42 additions and 0 deletions
  1. +42
    -0
      dib/ironic-ramdisk-base/cleanup.d/98-prepare-resolve-conf

+ 42
- 0
dib/ironic-ramdisk-base/cleanup.d/98-prepare-resolve-conf View File

@ -0,0 +1,42 @@
#!/bin/bash
# dib-lint: disable=safe_sudo
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# NOTE(dtantsur): this a copy of code from img-functions. We need it because it
# runs too late when the image is already built.
# Finalise resolv.conf
#
# NOTE(ianw): the /etc/resolv.conf.ORIG file is an
# external interface; elements might put a resolv.conf they
# want in the final image into this file.
#
# In create_base() we replaced/created the initial resolv.conf
# inside the image with a copy of the "outside" version so that
# resolving during the build will work.
#
# If that file has been replace with a symlink (resolvconf package
# can do this), or marked immutable, then don't restore the
# original version, just leave it alone.
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || \
lsattr $TMP_MOUNT_PATH/etc/resolv.conf | grep '^....i' >/dev/null ; then
# We're keeping the contents of resolv.conf set in the elements,
# so remove the old saved file
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG
else
# Remove the resolv.conf we created and put the original (or
# perhaps modified) version back.
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
# Note that we use -L and -f to test here as test (and bash [[)
# return false with -e if the link target does not exist.
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf
fi
fi

Loading…
Cancel
Save