diff --git a/bin/xen-create-image b/bin/xen-create-image index e27e740..3f651fe 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -742,7 +742,7 @@ use Digest::MD5 qw/ md5_hex /; use Env; use File::Path qw/ mkpath /; use File::Temp qw/ tempdir /; -use File::Copy qw/ cp /; +use File::Copy qw/ mv cp /; use Getopt::Long; use Pod::Usage; @@ -3516,6 +3516,11 @@ sub runCustomisationHooks } } + # + # Copy dom0's resolv.conf to domU + # + mv("$MOUNT_POINT/etc/resolv.conf", "$MOUNT_POINT/etc/resolv.conf.old") if -f "$MOUNT_POINT/etc/resolv.conf"; + cp("/etc/resolv.conf", "$MOUNT_POINT/etc/resolv.conf"); # # Actually run the appropriate hooks @@ -3530,11 +3535,19 @@ sub runCustomisationHooks runCommand($customize); logprint("Done\n"); + # + # Restore domU's resolv.conf if needed + # + if (-f "$MOUNT_POINT/etc/resolv.conf") { + mv("$MOUNT_POINT/etc/resolv.conf.old", "$MOUNT_POINT/etc/resolv.conf"); + } else { + unlink "$MOUNT_POINT/etc/resolv.conf"; + } + # # Unmount /proc in the guest install. # runCommand("umount $MOUNT_POINT/proc"); - } diff --git a/bin/xen-update-image b/bin/xen-update-image index 307088c..b7fa08c 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -105,6 +105,7 @@ The LICENSE file contains the full text of the license. use strict; use English; use File::Temp qw/ tempdir /; +use File::Copy qw/ mv cp /; use Getopt::Long; use Pod::Usage; @@ -287,6 +288,11 @@ sub updateXenImage if ( ( -e $tmp . "/usr/bin/apt-get" ) && ( -x $tmp . "/usr/bin/apt-get" ) ) { + # + # Copy dom0's resolv.conf to domU + # + mv("$tmp/etc/resolv.conf", "$tmp/etc/resolv.conf.old") if -f "$tmp/etc/resolv.conf"; + cp("/etc/resolv.conf", "$tmp/etc/resolv.conf"); # # Now run the update command. @@ -300,6 +306,15 @@ sub updateXenImage system( "DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes" ); + + # + # Restore domU's resolv.conf if needed + # + if (-f "$tmp/etc/resolv.conf") { + mv("$tmp/etc/resolv.conf.old", "$tmp/etc/resolv.conf"); + } else { + unlink "$tmp/etc/resolv.conf"; + } } else { diff --git a/hooks/centos-4/20-setup-yum b/hooks/centos-4/20-setup-yum index 96c1f14..8fed170 100755 --- a/hooks/centos-4/20-setup-yum +++ b/hooks/centos-4/20-setup-yum @@ -26,11 +26,6 @@ fi logMessage Script $0 starting -# -# DNS is probably required to run "yum update". -# -cp /etc/resolv.conf ${prefix}/etc - # # Update yum # diff --git a/hooks/centos-5/20-setup-yum b/hooks/centos-5/20-setup-yum index a962f7e..acb363d 100755 --- a/hooks/centos-5/20-setup-yum +++ b/hooks/centos-5/20-setup-yum @@ -26,12 +26,6 @@ fi logMessage Script $0 starting -# -# DNS is probably required to run "yum update". -# -cp /etc/resolv.conf ${prefix}/etc - - # # Update yum # diff --git a/hooks/dapper/20-setup-apt b/hooks/dapper/20-setup-apt index 2566236..475f8c6 100755 --- a/hooks/dapper/20-setup-apt +++ b/hooks/dapper/20-setup-apt @@ -28,12 +28,6 @@ fi logMessage Script $0 starting -# -# You will probably need DNS to run "apt-get update" -# -cp /etc/resolv.conf ${prefix}/etc - - # # Attempt to auto-magically detect the use of a Proxy for apt-get, and # replicate that setup in our new guest. diff --git a/hooks/debian/20-setup-apt b/hooks/debian/20-setup-apt index 9c8189b..28097d4 100755 --- a/hooks/debian/20-setup-apt +++ b/hooks/debian/20-setup-apt @@ -27,12 +27,6 @@ fi logMessage Script $0 starting -# -# You'll probably need DNS to run "apt-get update". -# -cp /etc/resolv.conf ${prefix}/etc - - # # Attempt to auto-magically detect the use of a Proxy for apt-get, and # replicate that setup in our new guest. diff --git a/hooks/edgy/20-setup-apt b/hooks/edgy/20-setup-apt index 557e914..a0e185f 100755 --- a/hooks/edgy/20-setup-apt +++ b/hooks/edgy/20-setup-apt @@ -28,12 +28,6 @@ fi logMessage Script $0 starting -# -# You will probably need DNS to run "apt-get update" -# -cp /etc/resolv.conf ${prefix}/etc - - # # Attempt to auto-magically detect the use of a Proxy for apt-get, and # replicate that setup in our new guest. diff --git a/hooks/fedora-core-6/20-setup-yum b/hooks/fedora-core-6/20-setup-yum index dfbf5e9..84a7ddf 100755 --- a/hooks/fedora-core-6/20-setup-yum +++ b/hooks/fedora-core-6/20-setup-yum @@ -26,13 +26,6 @@ fi logMessage Script $0 starting -# -# DNS is probably required to run "yum update". -# -cp /etc/resolv.conf ${prefix}/etc - - - # # Update yum # diff --git a/hooks/gentoo/60-copy-host-files b/hooks/gentoo/60-copy-host-files index 253ded5..6202ad1 100755 --- a/hooks/gentoo/60-copy-host-files +++ b/hooks/gentoo/60-copy-host-files @@ -24,12 +24,6 @@ fi logMessage Script $0 starting -# -# Copy "required" files from our host. -# -cp /etc/resolv.conf ${prefix}/etc - - # # If the host has sudo then copy the configuration file, and install # the package @@ -41,7 +35,6 @@ if [ -e /etc/sudoers ]; then # # Copy file and fixup permissions. # - cp /etc/resolv.conf ${prefix}/etc chown root:root ${prefix}/etc/sudoers chmod 440 ${prefix}/etc/sudoers diff --git a/hooks/intrepid/20-setup-apt b/hooks/intrepid/20-setup-apt index 557e914..a0e185f 100755 --- a/hooks/intrepid/20-setup-apt +++ b/hooks/intrepid/20-setup-apt @@ -28,12 +28,6 @@ fi logMessage Script $0 starting -# -# You will probably need DNS to run "apt-get update" -# -cp /etc/resolv.conf ${prefix}/etc - - # # Attempt to auto-magically detect the use of a Proxy for apt-get, and # replicate that setup in our new guest. diff --git a/hooks/karmic/20-setup-apt b/hooks/karmic/20-setup-apt index 557e914..a0e185f 100755 --- a/hooks/karmic/20-setup-apt +++ b/hooks/karmic/20-setup-apt @@ -28,12 +28,6 @@ fi logMessage Script $0 starting -# -# You will probably need DNS to run "apt-get update" -# -cp /etc/resolv.conf ${prefix}/etc - - # # Attempt to auto-magically detect the use of a Proxy for apt-get, and # replicate that setup in our new guest.