Merge "Respect inmutable resolv.conf in the image"

This commit is contained in:
Jenkins 2014-04-27 23:22:22 +00:00 committed by Gerrit Code Review
commit 1877784d3b

View File

@ -91,12 +91,19 @@ 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
# If the file has been set immutable, we probably want to keep it
if 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 above # Remove the resolv.conf we created above
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
# Move the original back # Move the original back
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then 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 sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf
fi fi
fi
} }
function compress_and_save_image () { function compress_and_save_image () {