1
0
mirror of synced 2026-01-20 17:38:02 +00:00

2005-12-20 13:27:03 by steve

Patch from Radu Spineanu.  Ensure that xm command exists.  Make --from
 mandatory when duplicating image.
This commit is contained in:
steve 2005-12-20 13:27:03 +00:00
parent c4e083b4b5
commit eccd8be48a
2 changed files with 50 additions and 8 deletions

View File

@ -203,7 +203,7 @@ broadcast = 255.255.255.0
--
http://www.steve.org.uk/
$Id: xen-create-image,v 1.35 2005-12-20 00:35:10 steve Exp $
$Id: xen-create-image,v 1.36 2005-12-20 13:27:03 steve Exp $
=cut
@ -249,12 +249,17 @@ my %CONFIG;
#
# Constants for filesystem usage.
#
my %FILESYSTEM_BINARY;
my %FILESYSTEM_CREATE;
my %FILESYSTEM_MOUNT;
$FILESYSTEM_CREATE{'ext3'} = '/sbin/mkfs.ext3 -F ';
$FILESYSTEM_CREATE{'xfs'} = '/sbin/mkfs.xfs -d name=';
$FILESYSTEM_CREATE{'reiserfs'} = '/sbin/mkfs.reiserfs -f -q ';
$FILESYSTEM_BINARY{'ext3'} = '/sbin/mkfs.ext3';
$FILESYSTEM_BINARY{'xfs'} = '/sbin/mkfs.xfs';
$FILESYSTEM_BINARY{'reiserfs'} = '/sbin/mkfs.reiserfs';
$FILESYSTEM_CREATE{'ext3'} = $FILESYSTEM_BINARY{'ext3'}. ' -F ';
$FILESYSTEM_CREATE{'xfs'} = $FILESYSTEM_BINARY{'xfs'}. ' -d name=';
$FILESYSTEM_CREATE{'reiserfs'} = $FILESYSTEM_BINARY{'reiserfs'}. ' -f -q ';
$FILESYSTEM_MOUNT{'ext3'} = '-t ext3';
$FILESYSTEM_MOUNT{'xfs'} = '-t xfs';
@ -276,7 +281,7 @@ $CONFIG{'swap'} = '128M';
$CONFIG{'fs'} = 'ext3';
$CONFIG{'mirror'} = 'http://ftp.us.debian.org/debian';
$CONFIG{'dist'} = 'sarge';
$CONFIG{'xm'} = '/usr/sbin/xm';
#
# Read configuration file(s) if they exist.
@ -635,7 +640,7 @@ if ( $CONFIG{'boot'} )
}
else
{
system( "xm create $CONFIG{'hostname'}.cfg" );
system( "$CONFIG{'xm'} create $CONFIG{'hostname'}.cfg" );
}
}
@ -798,6 +803,21 @@ EOF
exit;
}
#
# Make sure we have every binary we need
#
if ( ! -x $CONFIG{'xm'} )
{
print "Could not find " .$CONFIG{'xm'}. ".\n";
exit;
}
my $binpath = $FILESYSTEM_BINARY{lc( $CONFIG{'fs'} ) };
if ( ! -x $binpath ) {
print "Unable to find required executable ". $binpath. ".\n";
exit;
}
#
# Make sure we have a valid size
#

View File

@ -100,7 +100,7 @@ Specify the virtual instance that we should copy.
--
http://www.steve.org.uk/
$Id: xen-duplicate-image,v 1.3 2005-12-19 15:04:25 steve Exp $
$Id: xen-duplicate-image,v 1.4 2005-12-20 13:27:03 steve Exp $
=cut
@ -138,6 +138,8 @@ use Pod::Usage;
#
my %CONFIG;
$CONFIG{'xm'} = '/usr/sbin/xm';
#
# Read configuration file(s) if they exist.
@ -326,7 +328,7 @@ if ( $CONFIG{'boot'} )
}
else
{
system( "xm create $CONFIG{'hostname'}.cfg" );
system( "$CONFIG{'xm'} create $CONFIG{'hostname'}.cfg" );
}
}
@ -445,6 +447,18 @@ EOF
exit;
}
if (!defined ($CONFIG{'from'} ) )
{
print<<EOF
You should set a source with '--from=bar'.
This option is required.
EOF
;
exit;
}
if (!defined( $CONFIG{'dir'} ) )
{
@ -460,6 +474,14 @@ EOF
exit;
}
#
# Make sure we have every binary we need
#
if ( ! -x $CONFIG{'xm'} )
{
print "Could not find " .$CONFIG{'xm'}. ".\n";
exit;
}
#