diff --git a/bin/xen-create-image b/bin/xen-create-image index 2f7aa93..345ff64 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -446,7 +446,7 @@ Install an X11 server, using VNC and XDM -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.76 2006-08-18 12:07:46 steve Exp $ + $Id: xen-create-image,v 1.77 2006-08-18 13:09:24 steve Exp $ =cut @@ -576,7 +576,7 @@ elsif ( $CONFIG{'lvm'} ) else { # Can't happen: Neither loopback nor LVM selected - print "Error: Neither loopback nor LVM is selected.\n"; + logprint( "Error: Neither loopback nor LVM is selected.\n"); exit; } @@ -598,7 +598,7 @@ installSystem(); # if ( ! -x $MOUNT_POINT . "/bin/ls" ) { - print "System installation failed. Aborting\n"; + logprint( "System installation failed. Aborting\n"); exit; } @@ -631,7 +631,7 @@ setupRootPassword() if ( $CONFIG{'passwd'} ); # # Report success. # -print "All done\n"; +logprint( "All done\n"); # @@ -690,8 +690,8 @@ sub checkSystem { if ( ! -x "/usr/bin/" . $bin ) { - print "The script '$bin' was not found.\n"; - print "Aborting\n\n"; + logprint("The script '$bin' was not found.\n"); + logprint( "Aborting\n\n" ); exit; } } @@ -926,14 +926,14 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.76 $'; + my $REVISION = '$Revision: 1.77 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { $REVISION = $1; } - print "xen-create-image release $RELEASE - CVS: $REVISION\n"; + logprint( "xen-create-image release $RELEASE - CVS: $REVISION\n" ); exit; } @@ -966,7 +966,7 @@ sub parseCommandLineArguments } elsif ( $count > 1 ) { - print < 1 ) { - print <>", "/var/log/xen-tools/$CONFIG{'hostname'}.log" ) + or return; + print LOGFILE $text; + close( LOGFILE ); } } @@ -1944,43 +1978,25 @@ sub runCommand $CONFIG{'verbose'} && print "Executing : $cmd\n"; # - # Hide output unless running with --verbose. + # Copy stderr to stdout, so we can see it, and make sure we &logprint it. # - if ( $CONFIG{'verbose'} ) - { - # - # Copy stderr to stdout, so we can see it. - # - $cmd .= " 2>&1"; - } - else - { - $cmd .= " >/dev/null 2>/dev/null" ; - } + $cmd .= " 2>&1 | tee --append /var/log/xen-tools/$CONFIG{'hostname'}.log"; # # Run it. # my $output = `$cmd`; - # - # All done. - # - $CONFIG{'verbose'} && print "Output\n"; - $CONFIG{'verbose'} && print "======\n"; - $CONFIG{'verbose'} && print $output . "\n"; - $CONFIG{'verbose'} && print "Finished : $cmd\n"; + $CONFIG{'verbose'} && print "Finished : $cmd\n"; if ( $? != 0 ) { - print "Running command '$cmd' failed.\n"; - print "Aborting\n"; + logprint( "Running command '$cmd' failed.\n" ); + logpring( "Aborting\n" ); exit; } - - return( $output ); } @@ -2008,4 +2024,11 @@ sub END runCommand( "umount $MOUNT_POINT" ); } } + + if ( ( defined( $CONFIG{'hostname'} ) ) && + ( -e "/var/log/xen-tools/$CONFIG{'hostname'}.log" ) ) + { + print "\n\nLogfile produced at:\n"; + print "\t /var/log/xen-tools/$CONFIG{'hostname'}.log\n"; + } } diff --git a/bin/xt-install-image b/bin/xt-install-image index abf604e..2498948 100755 --- a/bin/xt-install-image +++ b/bin/xt-install-image @@ -80,7 +80,7 @@ Install the distribution specified by the B<--dist> argument using the debootstr -- http://www.steve.org.uk/ - $Id: xt-install-image,v 1.26 2006-08-18 08:57:28 steve Exp $ + $Id: xt-install-image,v 1.27 2006-08-18 13:09:24 steve Exp $ =cut @@ -237,7 +237,7 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.26 $'; + my $REVISION = '$Revision: 1.27 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { @@ -426,15 +426,6 @@ sub installDebootstrapImage # runCommand( $command ); - # - # Since we used the '--keep-debootstrap-dir' argument we'll have - # a /debootstrap/ directory maintained on the new guest. - # - # If we got this far then the debootstrap command invokation succeeded - # and we can remove it. - # - system( "/bin/rm", "-rf", $CONFIG{'location'} . "/debootstrap" ); - # # Cache from host -> new installation if we've got caching