Respect inmutable resolv.conf in the image
In some instances, the content of the image may want to convey specific resolv.conf settings. For instance, if unbound is installed, it's also desirable to set resolv.conf to point to it. Short circuit diskimage-builder's friendliness around resolv.conf files by not dying in a fire if it finds the file to be immutable. Change-Id: I88632fb79289681dcf95d32f39a0ad658ba39a60
This commit is contained in:
parent
1c07d4ba1a
commit
0c08692e75
@ -91,11 +91,18 @@ function prepare_first_boot () {
|
|||||||
|
|
||||||
function finalise_base () {
|
function finalise_base () {
|
||||||
TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup
|
TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup
|
||||||
# Remove the resolv.conf we created above
|
# If the file has been set immutable, we probably want to keep it
|
||||||
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
|
if lsattr $TMP_MOUNT_PATH/etc/resolv.conf | grep '^....i' >/dev/null ; then
|
||||||
# Move the original back
|
# We're keeping the contents of resolv.conf set in the elements,
|
||||||
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then
|
# so remove the old saved file
|
||||||
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf
|
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG
|
||||||
|
else
|
||||||
|
# Remove the resolv.conf we created above
|
||||||
|
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
|
||||||
|
# Move the original back
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user