1
0
mirror of synced 2026-02-18 04:53:47 +00:00

2006-06-13 13:21:22 by steve

TABs become spaces.  Tabs are evil.
This commit is contained in:
steve
2006-06-13 13:21:23 +00:00
parent fdcb4dbfc0
commit 2bb8a1b394
17 changed files with 768 additions and 770 deletions

View File

@@ -40,7 +40,7 @@ xen-create-image - Create a new Xen instance
Networking options:
--dhcp Setup the image to get an IP address via DHCP
--gateway Setup the iamge's network gateway.
--ip Setup the ip
--ip Setup the ip
--netmask Setup the netmask
Mandatory options:
@@ -394,7 +394,7 @@ Install an X11 server, using VNC and XDM
--
http://www.steve.org.uk/
$Id: xen-create-image,v 1.25 2006-06-13 08:18:08 steve Exp $
$Id: xen-create-image,v 1.26 2006-06-13 13:21:22 steve Exp $
=cut
@@ -582,13 +582,13 @@ sub checkSystem
{
if ( ! -x "/usr/bin/xt-customize-image" )
{
print "The script 'xt-customize-image' was not found.";
print "\nAborting\n\n";
print "The script 'xt-customize-image' was not found.";
print "\nAborting\n\n";
}
if ( ! -x "/usr/bin/xt-install-image" )
{
print "The script 'xt-install-image' was not found.";
print "\nAborting\n\n";
print "The script 'xt-install-image' was not found.";
print "\nAborting\n\n";
}
}
@@ -607,30 +607,30 @@ sub setupDefaultOptions
# Paths and files.
#
$CONFIG{'dir'} = '';
$CONFIG{'xm'} = '/usr/sbin/xm';
$CONFIG{'kernel'} = '/boot/vmlinuz-2.6.16-1-xen-686';
$CONFIG{'initrd'} = '/boot/initrd.img-2.6.16-1-xen-686';
$CONFIG{'xm'} = '/usr/sbin/xm';
$CONFIG{'kernel'} = '/boot/vmlinuz-2.6.16-1-xen-686';
$CONFIG{'initrd'} = '/boot/initrd.img-2.6.16-1-xen-686';
#
# Sizing options.
#
$CONFIG{'memory'} = '96Mb';
$CONFIG{'size'} = '2000Mb';
$CONFIG{'swap'} = '128M';
$CONFIG{'cache'} = 'yes';
$CONFIG{'memory'} = '96Mb';
$CONFIG{'size'} = '2000Mb';
$CONFIG{'swap'} = '128M';
$CONFIG{'cache'} = 'yes';
#
# Misc. options.
#
$CONFIG{'mirror'} = 'http://ftp.us.debian.org/debian';
$CONFIG{'dist'} = 'sarge';
$CONFIG{'fs'} = 'ext3';
$CONFIG{'force'} = 0;
$CONFIG{'mirror'} = 'http://ftp.us.debian.org/debian';
$CONFIG{'dist'} = 'sarge';
$CONFIG{'fs'} = 'ext3';
$CONFIG{'force'} = 0;
#
# Installation methods
#
$CONFIG{'rpmstrap'} = 0;
$CONFIG{'rpmstrap'} = 0;
$CONFIG{'debootstrap'} = 0;
$CONFIG{'copy'} = '';
$CONFIG{'tar'} = '';
@@ -642,9 +642,9 @@ sub setupDefaultOptions
# NOTE: These commands end in a trailing slash. The last parameter is
# added as the loopback file/LVM volume to create the fs on....
#
$CONFIG{'make_fs_ext3'} = '/sbin/mkfs.ext3 -F ';
$CONFIG{'make_fs_xfs'} = '/sbin/mkfs.xfs -d name=';
$CONFIG{'make_fs_reiserfs'} = '/sbin/mkfs.reiserfs -f -q ';
$CONFIG{'make_fs_ext3'} = '/sbin/mkfs.ext3 -F ';
$CONFIG{'make_fs_xfs'} = '/sbin/mkfs.xfs -d name=';
$CONFIG{'make_fs_reiserfs'} = '/sbin/mkfs.reiserfs -f -q ';
#
# Flags to pass to "mount" to mount our image.
@@ -676,39 +676,39 @@ sub readConfigurationFile
while (defined($line = <FILE>) )
{
chomp $line;
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length( $line ) < 1 );
# Skip blank lines
next if ( length( $line ) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Store value.
$CONFIG{ $key } = $val;
}
# Store value.
$CONFIG{ $key } = $val;
}
}
close( FILE );
@@ -724,51 +724,51 @@ sub readConfigurationFile
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
#
# Parse options.
#
GetOptions(
# Mandatory
"dist=s", \$CONFIG{'dist'},
# Mandatory
"dist=s", \$CONFIG{'dist'},
# Locations
"dir=s", \$CONFIG{'dir'},
"kernel=s", \$CONFIG{'kernel'},
"initrd=s", \$CONFIG{'initrd'},
"lvm=s", \$CONFIG{'lvm'},
# Locations
"dir=s", \$CONFIG{'dir'},
"kernel=s", \$CONFIG{'kernel'},
"initrd=s", \$CONFIG{'initrd'},
"lvm=s", \$CONFIG{'lvm'},
# Networking options
"dhcp", \$CONFIG{'dhcp'},
"gateway=s", \$CONFIG{'gateway'},
"hostname=s", \$CONFIG{'hostname'},
"ip=s@", \$CONFIG{'ip'},
"netmask=s", \$CONFIG{'netmask'},
# Networking options
"dhcp", \$CONFIG{'dhcp'},
"gateway=s", \$CONFIG{'gateway'},
"hostname=s", \$CONFIG{'hostname'},
"ip=s@", \$CONFIG{'ip'},
"netmask=s", \$CONFIG{'netmask'},
# Exclusive
"copy=s", \$CONFIG{'copy'},
"debootstrap", \$CONFIG{'debootstrap'},
"rpmstrap", \$CONFIG{'rpmstrap'},
"tar=s", \$CONFIG{'tar'},
# Exclusive
"copy=s", \$CONFIG{'copy'},
"debootstrap", \$CONFIG{'debootstrap'},
"rpmstrap", \$CONFIG{'rpmstrap'},
"tar=s", \$CONFIG{'tar'},
# Misc. options
"boot", \$CONFIG{'boot'},
"cache=s", \$CONFIG{'cache'},
# Misc. options
"boot", \$CONFIG{'boot'},
"cache=s", \$CONFIG{'cache'},
"ide", \$CONFIG{'ide'},
"passwd", \$CONFIG{'passwd'},
"role=s", \$CONFIG{'role'},
"force", \$CONFIG{'force'},
"passwd", \$CONFIG{'passwd'},
"role=s", \$CONFIG{'role'},
"force", \$CONFIG{'force'},
# Help options
"debug", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"verbose", \$CONFIG{'verbose'},
"version", \$VERSION
);
# Help options
"debug", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"verbose", \$CONFIG{'verbose'},
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -776,15 +776,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.25 $';
my $REVISION = '$Revision: 1.26 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-create-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xen-create-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -800,7 +800,7 @@ sub testRootUser
{
if ( $EFFECTIVE_USER_ID != 0 )
{
print <<E_O_ROOT;
print <<E_O_ROOT;
In order to use this script you must be running with root privileges.
@@ -808,7 +808,7 @@ sub testRootUser
E_O_ROOT
exit;
exit;
}
}
@@ -827,8 +827,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'dist'} ) )
{
print "The '--dist' argument is mandatory\n";
exit 1;
print "The '--dist' argument is mandatory\n";
exit 1;
}
#
@@ -843,7 +843,7 @@ sub checkArguments
if ( ! -d $dir )
{
print <<E_OR;
print <<E_OR;
We're trying to configure an installation of $CONFIG{'dist'} in
$CONFIG{'dir'} - but there is no hook directory for us to use.
@@ -854,7 +854,7 @@ sub checkArguments
Aborting.
E_OR
exit 1;
exit 1;
}
}
@@ -896,8 +896,8 @@ sub showSummery
foreach my $i ( @$ips )
{
print "IP Address $count : $i\n";
$count += 1;
print "IP Address $count : $i\n";
$count += 1;
}
$CONFIG{'dhcp'} && print "IP Address : DHCP\n";
@@ -948,17 +948,17 @@ sub createLoopbackImages
#
if ( ( -e $disk ) && ! $CONFIG{'force'} )
{
print "The disk image already exists. Aborting.\n";
print "Specify '--force' to overwrite, or remove the following file\n";
print $disk . "\n";
exit;
print "The disk image already exists. Aborting.\n";
print "Specify '--force' to overwrite, or remove the following file\n";
print $disk . "\n";
exit;
}
if ( ( -e $swap ) && ! $CONFIG{'force'} )
{
print "The swap image already exists. Aborting.\n";
print "Specify '--force' to overwrite, or remove the following file\n";
print $swap . "\n";
exit;
print "The swap image already exists. Aborting.\n";
print "Specify '--force' to overwrite, or remove the following file\n";
print $swap . "\n";
exit;
}
@@ -973,11 +973,11 @@ sub createLoopbackImages
#
if ( $disk_size =~ /^(\d+)Gb*$/i )
{
$disk_size = $1 * 1024 . "M";
$disk_size = $1 * 1024 . "M";
}
if ( $swap_size =~ /^(\d+)Gb*$/i )
{
$swap_size = $1 * 1024 . "M";
$swap_size = $1 * 1024 . "M";
}
#
@@ -986,7 +986,7 @@ sub createLoopbackImages
$disk_size =~ s/Mb*$/k/i;
if ( $swap_size =~ /^(\d+)Mb*$/i )
{
$swap_size = $1;
$swap_size = $1;
}
@@ -1045,11 +1045,11 @@ sub createLVMBits
#
if ( $disk_size =~ /^(\d+)Gb*$/i )
{
$disk_size = $1 * 1024 . "M";
$disk_size = $1 * 1024 . "M";
}
if ( $swap_size =~ /^(\d+)Gb*$/i )
{
$swap_size = $1 * 1024 . "M";
$swap_size = $1 * 1024 . "M";
}
#
@@ -1058,7 +1058,7 @@ sub createLVMBits
$disk_size =~ s/Mb*$/k/i;
if ( $swap_size =~ /^(\d+)Mb*$/i )
{
$swap_size = $1;
$swap_size = $1;
}
@@ -1103,19 +1103,19 @@ sub createFilesystem
#
if ( $command =~ /([^ ]+) (.*)$/ )
{
my $binary = $1;
my $args = $2;
my $binary = $1;
my $args = $2;
if ( ! -x $binary )
{
print "The binary '$binary' required to create the filesystem $CONFIG{'fs'} is missing\n";
exit;
}
if ( ! -x $binary )
{
print "The binary '$binary' required to create the filesystem $CONFIG{'fs'} is missing\n";
exit;
}
}
else
{
print "The filesystem creation hash is bogus for filesystem : $CONFIG{'fs'}\n";
exit;
print "The filesystem creation hash is bogus for filesystem : $CONFIG{'fs'}\n";
exit;
}
#
@@ -1127,7 +1127,7 @@ sub createFilesystem
#
if ( $CONFIG{'fs'} && $CONFIG{'force'} )
{
$command .= " -f ";
$command .= " -f ";
}
#
@@ -1160,16 +1160,16 @@ sub mountImage
if ( $CONFIG{'lvm'} )
{
$image = "/dev/" . $CONFIG{'lvm'} . "/" . $CONFIG{'hostname'} . '-disk';
$image = "/dev/" . $CONFIG{'lvm'} . "/" . $CONFIG{'hostname'} . '-disk';
}
elsif ( $CONFIG{'dir'} )
{
$image = $CONFIG{'dir'} . '/domains/' . $CONFIG{'hostname'} . "/disk.img" ;
$image = $CONFIG{'dir'} . '/domains/' . $CONFIG{'hostname'} . "/disk.img" ;
}
else
{
print "I don't know what to mount!\n";
exit;
print "I don't know what to mount!\n";
exit;
}
@@ -1189,11 +1189,11 @@ sub mountImage
#
if ( $CONFIG{'lvm'} )
{
$mount_cmd = "mount $mount_type $image $MOUNT_POINT";
$mount_cmd = "mount $mount_type $image $MOUNT_POINT";
}
else
{
$mount_cmd = "mount $mount_type -o loop $image $MOUNT_POINT";
$mount_cmd = "mount $mount_type -o loop $image $MOUNT_POINT";
}
runCommand( $mount_cmd );
@@ -1230,24 +1230,24 @@ sub installSystem
#
if ( $CONFIG{'copy'} )
{
$cmd .= " --copy=$CONFIG{'copy'}";
print "copy from $CONFIG{'copy'}\n";
$cmd .= " --copy=$CONFIG{'copy'}";
print "copy from $CONFIG{'copy'}\n";
}
if ( $CONFIG{'debootstrap'} )
{
$cmd .= " --debootstrap";
$cmd .= " --mirror=$CONFIG{'mirror'}";
print "debootstrap from $CONFIG{'mirror'}\n";
$cmd .= " --debootstrap";
$cmd .= " --mirror=$CONFIG{'mirror'}";
print "debootstrap from $CONFIG{'mirror'}\n";
}
if ( $CONFIG{'rpmstrap'} )
{
$cmd .= " --rpmstrap";
print "rpmstrap\n";
$cmd .= " --rpmstrap";
print "rpmstrap\n";
}
if ( $CONFIG{'tar'} )
{
$cmd .= " --tar=$CONFIG{'tar'}";
print "tarfile $CONFIG{'tar'}\n";
$cmd .= " --tar=$CONFIG{'tar'}";
print "tarfile $CONFIG{'tar'}\n";
}
@@ -1256,7 +1256,7 @@ sub installSystem
#
if ( $CONFIG{'verbose'} )
{
$cmd .= " --verbose";
$cmd .= " --verbose";
}
runCommand( $cmd );
@@ -1283,10 +1283,10 @@ sub runCustomisationHooks
#
foreach my $key ( keys %CONFIG )
{
if ( defined( $CONFIG{$key} ) )
{
$ENV{$key} = $CONFIG{$key};
}
if ( defined( $CONFIG{$key} ) )
{
$ENV{$key} = $CONFIG{$key};
}
}
#
@@ -1304,8 +1304,8 @@ sub runCustomisationHooks
foreach my $i ( @$ips )
{
$ENV{'ip' . $count } = $i;
$count += 1;
$ENV{'ip' . $count } = $i;
$count += 1;
}
$ENV{'ip_count'} = ($count - 1);
@@ -1315,12 +1315,12 @@ sub runCustomisationHooks
#
if ( $CONFIG{'verbose'} )
{
print "Customization Script Environment:\n";
print "---------------------------------\n";
foreach my $key ( sort keys %ENV )
{
print "\t'" . $key . "' = '" . $ENV{$key} . "'\n";
}
print "Customization Script Environment:\n";
print "---------------------------------\n";
foreach my $key ( sort keys %ENV )
{
print "\t'" . $key . "' = '" . $ENV{$key} . "'\n";
}
}
@@ -1330,7 +1330,7 @@ sub runCustomisationHooks
my $customize = "xt-customize-image --dist=$CONFIG{'dist'} --location=$MOUNT_POINT";
if ( $CONFIG{'verbose'} )
{
$customize .= " --verbose";
$customize .= " --verbose";
}
print "\nRunning hooks\n";
runCommand( $customize );
@@ -1348,25 +1348,25 @@ sub runCustomisationHooks
sub runRoleScript
{
my $roleDir = '/usr/lib/xen-tools/' . $CONFIG{'dist'} . '.d/role.d/' ;
my $role = $CONFIG{'role'};
my $roleDir = '/usr/lib/xen-tools/' . $CONFIG{'dist'} . '.d/role.d/' ;
my $role = $CONFIG{'role'};
if ( !defined( $role ) )
{
print "No role script specified\n";
return;
print "No role script specified\n";
return;
}
my $file = $roleDir . $role;
if ( -x $file )
{
print "Running role script $file for role '$role'\n";
print "Running role script $file for role '$role'\n";
}
else
{
print "Role script not executable : $file for role '$role'\n";
return;
print "Role script not executable : $file for role '$role'\n";
return;
}
@@ -1423,14 +1423,14 @@ sub runCommand
#
if ( $CONFIG{'verbose'} )
{
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
}
else
{
$cmd .= " >/dev/null 2>/dev/null" ;
$cmd .= " >/dev/null 2>/dev/null" ;
}
#
@@ -1449,9 +1449,9 @@ sub runCommand
if ( $? != 0 )
{
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
}
@@ -1472,13 +1472,13 @@ sub END
{
if ( defined( $MOUNT_POINT ) )
{
#
# Run mount to see if this is still mounted.
#
my $mount = `/bin/mount`;
if ( $mount =~ /$MOUNT_POINT/)
{
runCommand( "umount $MOUNT_POINT" );
}
#
# Run mount to see if this is still mounted.
#
my $mount = `/bin/mount`;
if ( $mount =~ /$MOUNT_POINT/)
{
runCommand( "umount $MOUNT_POINT" );
}
}
}

View File

@@ -80,7 +80,7 @@ Specify the LVM volume where images were previously saved.
--
http://www.steve.org.uk/
$Id: xen-delete-image,v 1.6 2006-06-10 16:48:55 steve Exp $
$Id: xen-delete-image,v 1.7 2006-06-13 13:21:22 steve Exp $
=cut
@@ -194,39 +194,39 @@ sub readConfigurationFile
while (defined($line = <FILE>) )
{
chomp $line;
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length( $line ) < 1 );
# Skip blank lines
next if ( length( $line ) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Store value.
$CONFIG{ $key } = $val;
}
# Store value.
$CONFIG{ $key } = $val;
}
}
close( FILE );
@@ -243,21 +243,21 @@ sub readConfigurationFile
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
# Parse options.
#
GetOptions(
"dir=s", \$CONFIG{'dir'},
"lvm=s", \$CONFIG{'lvm'},
"test", \$CONFIG{'test'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"dir=s", \$CONFIG{'dir'},
"lvm=s", \$CONFIG{'lvm'},
"test", \$CONFIG{'test'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -265,15 +265,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.6 $';
my $REVISION = '$Revision: 1.7 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-delete-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xen-delete-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -293,8 +293,8 @@ sub checkArguments
#
if ( $CONFIG{'lvm'} && $CONFIG{'dir'} )
{
print "Please only use a volume group or a directory name - not both\n";
exit;
print "Please only use a volume group or a directory name - not both\n";
exit;
}
@@ -303,8 +303,8 @@ sub checkArguments
#
if ( (!defined( $CONFIG{'dir'} ) ) && ( !defined( $CONFIG{'lvm'} ) ) )
{
print "Please specify either a directory root, or an LVM volume group\n";
exit;
print "Please specify either a directory root, or an LVM volume group\n";
exit;
}
}
@@ -326,7 +326,7 @@ sub deleteXenImage
#
if ( -e "/etc/xen/" . $hostname . ".cfg" )
{
unlink( "/etc/xen/" . $hostname . ".cfg" );
unlink( "/etc/xen/" . $hostname . ".cfg" );
}
@@ -335,71 +335,71 @@ sub deleteXenImage
#
if ( defined( $CONFIG{'dir'} ) )
{
my $prefix = $CONFIG{'dir'} . "/domains/";
my $prefix = $CONFIG{'dir'} . "/domains/";
#
# The files
#
my $swap = $prefix . $hostname . "/swap.img";
my $disk = $prefix . $hostname . "/disk.img";
my $log = $prefix . $hostname . "/install.log";
#
# The files
#
my $swap = $prefix . $hostname . "/swap.img";
my $disk = $prefix . $hostname . "/disk.img";
my $log = $prefix . $hostname . "/install.log";
#
# Swap
#
if ( -e $swap )
{
$CONFIG{'verbose'} && print "Removing swap: $swap\n";
unlink( $swap );
}
#
# Swap
#
if ( -e $swap )
{
$CONFIG{'verbose'} && print "Removing swap: $swap\n";
unlink( $swap );
}
#
# Disk
#
if ( -e $disk )
{
$CONFIG{'verbose'} && print "Removing disk: $disk\n";
unlink( $disk );
}
#
# Disk
#
if ( -e $disk )
{
$CONFIG{'verbose'} && print "Removing disk: $disk\n";
unlink( $disk );
}
#
# Install log
#
if ( -e $log )
{
$CONFIG{'verbose'} && print "Removing log: $log\n";
unlink( $log );
}
#
# Install log
#
if ( -e $log )
{
$CONFIG{'verbose'} && print "Removing log: $log\n";
unlink( $log );
}
#
# Now remove the directory.
#
if ( -d $prefix . $hostname )
{
$CONFIG{'verbose'} && print "Removing directory: $prefix" . $hostname . "\n";
rmdir ( $prefix . $hostname );
}
#
# Now remove the directory.
#
if ( -d $prefix . $hostname )
{
$CONFIG{'verbose'} && print "Removing directory: $prefix" . $hostname . "\n";
rmdir ( $prefix . $hostname );
}
}
elsif ( defined( $CONFIG{'lvm'} ) )
{
#
# LVM volumes
#
#
# TODO: Check we're not mounted.
#
my $swap = "lvremove /dev/$CONFIG{'lvm'}/$hostname-swap --force";
my $disk = "lvremove /dev/$CONFIG{'lvm'}/$hostname-disk --force";
#
# LVM volumes
#
#
# TODO: Check we're not mounted.
#
my $swap = "lvremove /dev/$CONFIG{'lvm'}/$hostname-swap --force";
my $disk = "lvremove /dev/$CONFIG{'lvm'}/$hostname-disk --force";
runCommand( $swap );
runCommand( $disk );
runCommand( $swap );
runCommand( $disk );
}
else
{
print "Error - neither --dir nor --lvm.\n";
print "Can't happen\n";
print "Hostname : $hostname\n";
exit;
print "Error - neither --dir nor --lvm.\n";
print "Can't happen\n";
print "Hostname : $hostname\n";
exit;
}
}
@@ -428,14 +428,14 @@ sub runCommand
#
if ( $CONFIG{'verbose'} )
{
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
}
else
{
$cmd .= " >/dev/null 2>/dev/null" ;
$cmd .= " >/dev/null 2>/dev/null" ;
}
@@ -446,9 +446,9 @@ sub runCommand
if ( $? != 0 )
{
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
}

View File

@@ -122,7 +122,7 @@ Specify the LVM volume where images are to go
--
http://www.steve.org.uk/
$Id: xen-duplicate-image,v 1.2 2006-06-09 19:04:13 steve Exp $
$Id: xen-duplicate-image,v 1.3 2006-06-13 13:21:22 steve Exp $
=cut
@@ -177,7 +177,7 @@ my $RELEASE = '2.0';
#
# Defaults
#
$CONFIG{'xm'} = '/usr/sbin/xm';
$CONFIG{'xm'} = '/usr/sbin/xm';
#
@@ -323,10 +323,10 @@ if ( -x "/etc/xen-tools/hook.d/95-create-cfg" )
#
foreach my $key ( keys %CONFIG )
{
if ( defined( $CONFIG{$key} ) )
{
$ENV{$key} = $CONFIG{$key};
}
if ( defined( $CONFIG{$key} ) )
{
$ENV{$key} = $CONFIG{$key};
}
}
$ENV{'imagevbd'} = "file:" . $image_out;
$ENV{'swapvbd'} = "file:" . $swap_out;
@@ -352,11 +352,11 @@ if ( $CONFIG{'boot'} )
my $pid = fork();
if ( $pid )
{
exit;
exit;
}
else
{
system( "$CONFIG{'xm'} create $CONFIG{'hostname'}.cfg >/dev/null 2>/dev/null" );
system( "$CONFIG{'xm'} create $CONFIG{'hostname'}.cfg >/dev/null 2>/dev/null" );
}
}
@@ -384,39 +384,39 @@ sub readConfigurationFile
while (defined($line = <FILE>) )
{
chomp $line;
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length( $line ) < 1 );
# Skip blank lines
next if ( length( $line ) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Store value.
$CONFIG{ $key } = $val;
}
# Store value.
$CONFIG{ $key } = $val;
}
}
close( FILE );
@@ -433,27 +433,27 @@ sub readConfigurationFile
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
# Parse options.
#
GetOptions(
"hostname=s", \$CONFIG{'hostname'},
"from=s", \$CONFIG{'from'},
"ip=s", \$CONFIG{'ip'},
"gateway=s", \$CONFIG{'gateway'},
"netmask=s", \$CONFIG{'netmask'},
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"kernel=s", \$CONFIG{'kernel'},
"dhcp", \$CONFIG{'dhcp'},
"hostname=s", \$CONFIG{'hostname'},
"from=s", \$CONFIG{'from'},
"ip=s", \$CONFIG{'ip'},
"gateway=s", \$CONFIG{'gateway'},
"netmask=s", \$CONFIG{'netmask'},
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"kernel=s", \$CONFIG{'kernel'},
"dhcp", \$CONFIG{'dhcp'},
"ide", \$CONFIG{'ide'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -461,15 +461,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.2 $';
my $REVISION = '$Revision: 1.3 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-duplicate-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xen-duplicate-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -488,14 +488,14 @@ sub checkArguments
if (!defined( $CONFIG{'hostname'} ) )
{
print<<EOF
print<<EOF
You should set a hostname with '--hostname=foo'.
This option is required.
EOF
;
exit;
exit;
}
if (!defined ($CONFIG{'from'} ) )
@@ -517,8 +517,8 @@ EOF
#
if ( $CONFIG{'volume'} && $CONFIG{'dir'} )
{
print "Please only use a volume or a directory name - not both\n";
exit;
print "Please only use a volume or a directory name - not both\n";
exit;
}
@@ -527,14 +527,14 @@ EOF
#
if ( $CONFIG{'volume'} )
{
print "LVM Volumes are not supported yet\n";
exit;
print "LVM Volumes are not supported yet\n";
exit;
}
if (!defined( $CONFIG{'dir'} ) )
{
print<<EOF
print<<EOF
You should set an output directory with '--dir=/my/path'.
@@ -542,8 +542,8 @@ EOF
beneath the directory you name.
EOF
;
exit;
;
exit;
}
#
@@ -561,14 +561,14 @@ EOF
#
if ( ! -d $CONFIG{'dir'} )
{
print "Output directory '$CONFIG{'dir'}' doesn't exist\n";
exit;
print "Output directory '$CONFIG{'dir'}' doesn't exist\n";
exit;
}
if ( ! -w $CONFIG{'dir'} )
{
print "Output directory '$CONFIG{'dir'}' isn't writable.\n";
exit;
print "Output directory '$CONFIG{'dir'}' isn't writable.\n";
exit;
}
#
@@ -577,15 +577,15 @@ EOF
my $source = $CONFIG{'dir'} . "/domains/" . $CONFIG{'from'} . "/disk.img";
if ( ! -e $source )
{
print "The source image you've specified doesn't exist";
exit;
print "The source image you've specified doesn't exist";
exit;
}
# Strip trailing Mb from the memory size.
if ( $CONFIG{'memory'} =~ /^(\d+)Mb*$/i )
{
$CONFIG{'memory'} = $1;
$CONFIG{'memory'} = $1;
}
#
@@ -593,9 +593,9 @@ EOF
#
if ( $CONFIG{'ip'} && $CONFIG{'dhcp'})
{
print "You've chosen both DHCP and an IP address.\n";
print "Only one is supported\n";
exit;
print "You've chosen both DHCP and an IP address.\n";
print "Only one is supported\n";
exit;
}
#
@@ -604,9 +604,9 @@ EOF
#
if ( $CONFIG{'dhcp'} )
{
$CONFIG{'gateway'} = '';
$CONFIG{'netmask'} = '';
$CONFIG{'ip'} = '';
$CONFIG{'gateway'} = '';
$CONFIG{'netmask'} = '';
$CONFIG{'ip'} = '';
}
}
@@ -629,7 +629,7 @@ sub setupNetworking
if ( $CONFIG{'dhcp'} )
{
print IP<<E_O_DHCP;
print IP<<E_O_DHCP;
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
@@ -645,7 +645,7 @@ E_O_DHCP
}
else
{
print IP<<E_O_STATIC_IP;
print IP<<E_O_STATIC_IP;
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

View File

@@ -94,7 +94,7 @@ Specify the LVM volume where images are located
--
http://www.steve.org.uk/
$Id: xen-list-images,v 1.2 2006-06-09 19:04:13 steve Exp $
$Id: xen-list-images,v 1.3 2006-06-13 13:21:22 steve Exp $
=cut
@@ -197,29 +197,29 @@ foreach my $entry ( glob( $dir . "*" ) )
# Disk && Swap files.
#
if ( ( -e $image ) &&
( -e $swap ) )
( -e $swap ) )
{
if ( $EFFECTIVE_USER_ID != 0 )
{
print "Image: $entry\n";
}
else
{
print "Image: $entry ";
if ( $EFFECTIVE_USER_ID != 0 )
{
print "Image: $entry\n";
}
else
{
print "Image: $entry ";
#
# Don't show the networking details if running with '--test'
#
if ( $CONFIG{'test'} )
{
print "\n";
}
else
{
showNetworkingDetails( $image );
}
}
#
# Don't show the networking details if running with '--test'
#
if ( $CONFIG{'test'} )
{
print "\n";
}
else
{
showNetworkingDetails( $image );
}
}
}
}
}
@@ -250,39 +250,39 @@ sub readConfigurationFile
while (defined($line = <FILE>) )
{
chomp $line;
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length( $line ) < 1 );
# Skip blank lines
next if ( length( $line ) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Store value.
$CONFIG{ $key } = $val;
}
# Store value.
$CONFIG{ $key } = $val;
}
}
close( FILE );
@@ -299,20 +299,20 @@ sub readConfigurationFile
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
# Parse options.
#
GetOptions(
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"test", \$CONFIG{'test'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"test", \$CONFIG{'test'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -320,15 +320,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.2 $';
my $REVISION = '$Revision: 1.3 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-list-images release $RELEASE - CVS: $REVISION\n";
exit;
print "xen-list-images release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -358,15 +358,15 @@ sub showNetworkingDetails
if ( -e $dir . "/etc/network/interfaces" )
{
showDebianNetworkingDetails( $dir );
showDebianNetworkingDetails( $dir );
}
elsif ( -e $dir . "/etc/sysconfig/network-scripts/ifcfg-eth0" )
{
showCentosNetworkingDetails( $dir );
showCentosNetworkingDetails( $dir );
}
else
{
print "Unknown distribution - No networking details.\n";
print "Unknown distribution - No networking details.\n";
}
@@ -395,16 +395,16 @@ sub showCentosNetworkingDetails
open( IN, "<", $dir . "/etc/sysconfig/network-scripts/ifcfg-eth0" );
foreach my $line ( <IN> )
{
if ( $line =~ /=[ \t]*dhci/i )
{
print " DHCP\n";
$found = 1;
}
if ( $line =~ /IPADDR[ \t]*=[ \t]*([1-9\.]+)/ )
{
print $1 . "\n";
$found = 1;
}
if ( $line =~ /=[ \t]*dhci/i )
{
print " DHCP\n";
$found = 1;
}
if ( $line =~ /IPADDR[ \t]*=[ \t]*([1-9\.]+)/ )
{
print $1 . "\n";
$found = 1;
}
}
close( IN );
if ( ! $found ) { print "Unknown IP address\n"; }
@@ -430,17 +430,17 @@ sub showDebianNetworkingDetails
open( IN, "<", $dir . "/etc/network/interfaces" );
foreach my $line ( <IN> )
{
if ( ( $line =~ /dhcp/ ) &&
( $line =~ /eth/ ) )
{
print " DHCP\n";
$found = 1;
}
if ( $line =~ /address ([0-9\.]+)/ )
{
print $1 . "\n";
$found = 1;
}
if ( ( $line =~ /dhcp/ ) &&
( $line =~ /eth/ ) )
{
print " DHCP\n";
$found = 1;
}
if ( $line =~ /address ([0-9\.]+)/ )
{
print $1 . "\n";
$found = 1;
}
}
close( IN );
if ( ! $found ) { print "Unknown IP address\n"; }

View File

@@ -83,7 +83,7 @@ Specify the LVM volume where images are located.
--
http://www.steve.org.uk/
$Id: xen-update-image,v 1.2 2006-06-09 19:04:13 steve Exp $
$Id: xen-update-image,v 1.3 2006-06-13 13:21:22 steve Exp $
=cut
@@ -209,8 +209,8 @@ sub updateXenImage
if ( ! -e $image )
{
print "Disk image '$image' for host '$name' not found\n";
exit;
print "Disk image '$image' for host '$name' not found\n";
exit;
}
@@ -225,22 +225,22 @@ sub updateXenImage
# Make sure this is a Debian image.
#
if ( ( -e $tmp . "/usr/bin/apt-get" ) &&
( -e $tmp . "/etc/apt/sources.list" ) )
( -e $tmp . "/etc/apt/sources.list" ) )
{
#
# Now run the update command.
#
system( "chroot $tmp /usr/bin/apt-get update" );
#
# Now run the update command.
#
system( "chroot $tmp /usr/bin/apt-get update" );
#
# Now upgrade
#
system( "DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes" );
#
# Now upgrade
#
system( "DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes" );
}
else
{
print "Xen image $name is not a Debian GNU/Linux image. Skipping\n";
print "Xen image $name is not a Debian GNU/Linux image. Skipping\n";
}
@@ -269,39 +269,39 @@ sub readConfigurationFile
while (defined($line = <FILE>) )
{
chomp $line;
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
if ($line =~ s/\\$//)
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length( $line ) < 1 );
# Skip blank lines
next if ( length( $line ) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Find variable settings
if ( $line =~ /([^=]+)=([^\n]+)/ )
{
my $key = $1;
my $val = $2;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Strip leading and trailing whitespace.
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
# Store value.
$CONFIG{ $key } = $val;
}
# Store value.
$CONFIG{ $key } = $val;
}
}
close( FILE );
@@ -318,33 +318,33 @@ sub readConfigurationFile
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
# Parse options.
#
GetOptions(
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"dir=s", \$CONFIG{'dir'},
"volume=s", \$CONFIG{'volume'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
if ( $VERSION )
{
my $REVISION = '$Revision: 1.2 $';
my $REVISION = '$Revision: 1.3 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-update-image release $RELEASE - CVS: $REVISION\n";
exit;
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xen-update-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}

View File

@@ -45,7 +45,7 @@ xt-create-config - Create a Xen configuration file for a new domain.
--
http://www.steve.org.uk/
$Id: xt-create-xen-config,v 1.7 2006-06-10 14:36:53 steve Exp $
$Id: xt-create-xen-config,v 1.8 2006-06-13 13:21:22 steve Exp $
=cut
@@ -119,20 +119,20 @@ exit 0;
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
#
# Parse options.
#
GetOptions(
"output=s", \$CONFIG{'output'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"output=s", \$CONFIG{'output'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -140,15 +140,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.7 $';
my $REVISION = '$Revision: 1.8 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -168,8 +168,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'output'} ) )
{
print "The '--output' argument is mandatory\n";
exit 1;
print "The '--output' argument is mandatory\n";
exit 1;
}
}
@@ -192,7 +192,7 @@ sub createXenConfig
my $device = 'sda';
if ( defined( $ENV{'ide'} ) )
{
$device = 'hda';
$device = 'hda';
}
#
@@ -200,21 +200,21 @@ sub createXenConfig
#
if ( $ENV{'memory'} =~ /([0-9]+)/ )
{
$ENV{'memory'} = $1;
$ENV{'memory'} = $1;
}
my $network = '';
if ( $ENV{'dhcp'} )
{
$network =<<EOF;
$network =<<EOF;
dhcp = "dhcp"
vif = [ '' ]
EOF
}
else
{
$network =<<EOF;
$network =<<EOF;
vif = [ 'ip=$ENV{'ip1'}' ]
EOF
}
@@ -228,13 +228,13 @@ EOF
if ( $ENV{'lvm'} )
{
$image_vbd = "phy:$ENV{'lvm'}/$ENV{'hostname'}-disk";
$swap_vbd = "phy:$ENV{'lvm'}/$ENV{'hostname'}-swap";
$image_vbd = "phy:$ENV{'lvm'}/$ENV{'hostname'}-disk";
$swap_vbd = "phy:$ENV{'lvm'}/$ENV{'hostname'}-swap";
}
else
{
$image_vbd = "file:$ENV{'dir'}/domains/$ENV{'hostname'}/disk.img";
$swap_vbd = "file:$ENV{'dir'}/domains/$ENV{'hostname'}/swap.img";
$image_vbd = "file:$ENV{'dir'}/domains/$ENV{'hostname'}/disk.img";
$swap_vbd = "file:$ENV{'dir'}/domains/$ENV{'hostname'}/swap.img";
}
#

View File

@@ -66,7 +66,7 @@ xt-customize-image - Customize a freshly installed copy of GNU/Linux
--
http://www.steve.org.uk/
$Id: xt-customize-image,v 1.8 2006-06-09 19:49:18 steve Exp $
$Id: xt-customize-image,v 1.9 2006-06-13 13:21:22 steve Exp $
=cut
@@ -141,21 +141,21 @@ exit 0;
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
#
# Parse options.
#
GetOptions(
"location=s", \$CONFIG{'location'},
"dist=s", \$CONFIG{'dist'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
"location=s", \$CONFIG{'location'},
"dist=s", \$CONFIG{'dist'},
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -163,15 +163,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.8 $';
my $REVISION = '$Revision: 1.9 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -191,8 +191,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'location'} ) )
{
print "The '--location' argument is mandatory\n";
exit 1;
print "The '--location' argument is mandatory\n";
exit 1;
}
@@ -202,9 +202,9 @@ sub checkArguments
#
if ( ! -d $CONFIG{'location'} )
{
print "The installation directory we've been given doesn't exist\n";
print "We tried to use : $CONFIG{'location'}\n";
exit 1;
print "The installation directory we've been given doesn't exist\n";
print "We tried to use : $CONFIG{'location'}\n";
exit 1;
}
@@ -213,8 +213,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'dist'} ) )
{
print "The '--dist' argument is mandatory\n";
exit 1;
print "The '--dist' argument is mandatory\n";
exit 1;
}
@@ -229,7 +229,7 @@ sub checkArguments
if ( ! -d $dir )
{
print <<E_OR;
print <<E_OR;
We're trying to configure an installation of $CONFIG{'dist'} in
$CONFIG{'location'} - but there is no hook directory for us to use.
@@ -240,7 +240,7 @@ sub checkArguments
Aborting.
E_OR
exit 1;
exit 1;
}
}
@@ -280,7 +280,7 @@ sub runDistributionHooks
#
if ( $CONFIG{'verbose'} )
{
$ENV{'verbose'} = 1;
$ENV{'verbose'} = 1;
}
#
@@ -293,43 +293,43 @@ sub runDistributionHooks
next if ( $file =~ /\.dpkg-(new|old)/ );
next if ( $file =~ /~$/ );
#
# Only run executable files.
#
if ( ( -x $file ) && ( -f $file ) )
{
#
# Just display the name - no need to see the full path.
#
my $name = $file;
if ( $file =~ /(.*)\/(.*)/ )
{
$name = $2;
}
#
# Only run executable files.
#
if ( ( -x $file ) && ( -f $file ) )
{
#
# Just display the name - no need to see the full path.
#
my $name = $file;
if ( $file =~ /(.*)\/(.*)/ )
{
$name = $2;
}
#
# Complete path to the file.
#
my $cmd = $hooks . $name . " $CONFIG{'location'}";
#
# Complete path to the file.
#
my $cmd = $hooks . $name . " $CONFIG{'location'}";
#
# Run the command. This has different prolog and epilog
# depending on whether we're running verbosely or not.
#
if ( $CONFIG{'verbose'} )
{
print "Running hook $name ['$cmd']\n";
print "--\n";
system( $cmd );
print "--\n";
print "Done\n\n";
}
else
{
print "Running hook $name";
system( $cmd );
print " - done.\n";
}
}
#
# Run the command. This has different prolog and epilog
# depending on whether we're running verbosely or not.
#
if ( $CONFIG{'verbose'} )
{
print "Running hook $name ['$cmd']\n";
print "--\n";
system( $cmd );
print "--\n";
print "Done\n\n";
}
else
{
print "Running hook $name";
system( $cmd );
print " - done.\n";
}
}
}
}

View File

@@ -79,7 +79,7 @@ Install the distribution specified by the B<--dist> argument using the debootstr
--
http://www.steve.org.uk/
$Id: xt-install-image,v 1.13 2006-06-10 16:48:55 steve Exp $
$Id: xt-install-image,v 1.14 2006-06-13 13:21:22 steve Exp $
=cut
@@ -175,10 +175,10 @@ foreach my $file ( qw( /bin/ls /bin/cp ) )
{
if ( ! -x $CONFIG{'location'} . $file )
{
print "The installation of the new system appears to have failed.\n";
print "\n";
print "There is no '$file' installed in the new installation directory\n";
exit 1;
print "The installation of the new system appears to have failed.\n";
print "\n";
print "There is no '$file' installed in the new installation directory\n";
exit 1;
}
}
@@ -199,34 +199,34 @@ exit 0;
sub parseCommandLineArguments
{
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
my $HELP = 0;
my $MANUAL = 0;
my $VERSION = 0;
#
# Parse options.
#
GetOptions(
# Mandatory
"location=s", \$CONFIG{'location'},
"dist=s", \$CONFIG{'dist'},
# Mandatory
"location=s", \$CONFIG{'location'},
"dist=s", \$CONFIG{'dist'},
# Exclusive.
"tar=s", \$CONFIG{'tar'},
"copy=s", \$CONFIG{'copy'},
"rpmstrap", \$CONFIG{'rpmstrap'},
"debootstrap", \$CONFIG{'debootstrap'},
# Exclusive.
"tar=s", \$CONFIG{'tar'},
"copy=s", \$CONFIG{'copy'},
"rpmstrap", \$CONFIG{'rpmstrap'},
"debootstrap", \$CONFIG{'debootstrap'},
# Misc
"mirror=s", \$CONFIG{'mirror'},
"cache=s", \$CONFIG{'cache'},
# Misc
"mirror=s", \$CONFIG{'mirror'},
"cache=s", \$CONFIG{'cache'},
# Help.
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
# Help.
"verbose", \$CONFIG{'verbose'},
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage(-verbose => 2 ) if $MANUAL;
@@ -234,15 +234,15 @@ sub parseCommandLineArguments
if ( $VERSION )
{
my $REVISION = '$Revision: 1.13 $';
my $REVISION = '$Revision: 1.14 $';
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
if ( $REVISION =~ /1.([0-9.]+) / )
{
$REVISION = $1;
}
print "xt-install-image release $RELEASE - CVS: $REVISION\n";
exit;
print "xt-install-image release $RELEASE - CVS: $REVISION\n";
exit;
}
}
@@ -262,8 +262,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'location'} ) )
{
print "The '--location' argument is mandatory\n";
exit 1;
print "The '--location' argument is mandatory\n";
exit 1;
}
@@ -273,9 +273,9 @@ sub checkArguments
#
if ( ! -d $CONFIG{'location'} )
{
print "The installation directory we've been given doesn't exist\n";
print "We tried to use : $CONFIG{'location'}\n";
exit 1;
print "The installation directory we've been given doesn't exist\n";
print "We tried to use : $CONFIG{'location'}\n";
exit 1;
}
@@ -284,8 +284,8 @@ sub checkArguments
#
if ( ! defined( $CONFIG{'dist'} ) )
{
print "The '--dist' argument is mandatory\n";
exit 1;
print "The '--dist' argument is mandatory\n";
exit 1;
}
@@ -300,7 +300,7 @@ sub checkArguments
if ( ! -d $dir )
{
print <<E_OR;
print <<E_OR;
We're trying to configure an installation of $CONFIG{'dist'} in
$CONFIG{'location'} - but there is no hook directory for us to use.
@@ -311,7 +311,7 @@ sub checkArguments
Aborting.
E_OR
exit 1;
exit 1;
}
@@ -321,10 +321,10 @@ E_OR
my $count = 0;
foreach my $key ( qw(copy debootstrap rpmstrap tar ) )
{
if ( defined( $CONFIG{$key} ) )
{
$count += 1;
}
if ( defined( $CONFIG{$key} ) )
{
$count += 1;
}
}
#
@@ -332,7 +332,7 @@ E_OR
#
if ( $count == 0 )
{
print <<EOF;
print <<EOF;
You did not specify an installation method.
One of the following must be given. (Run "xt-install-image --manual" for details)
@@ -349,7 +349,7 @@ EOF
}
elsif ( $count > 1 )
{
print <<EOF;
print <<EOF;
You specify multiple installation methods.
Only one of the following must be given:
@@ -361,7 +361,7 @@ EOF
Aborting.
EOF
exit 1;
exit 1;
}
}
@@ -383,10 +383,10 @@ sub installDebootstrapImage
#
if ( $CONFIG{'cache'} eq "yes" )
{
print "\nCopying files from host to image.\n";
runCommand( "mkdir -p $CONFIG{'location'}/var/cache/apt/archives" );
copyDebFiles( "/var/cache/apt/archives", "$CONFIG{'location'}/var/cache/apt/archives" );
print( "Done\n" );
print "\nCopying files from host to image.\n";
runCommand( "mkdir -p $CONFIG{'location'}/var/cache/apt/archives" );
copyDebFiles( "/var/cache/apt/archives", "$CONFIG{'location'}/var/cache/apt/archives" );
print( "Done\n" );
}
#
@@ -395,7 +395,7 @@ sub installDebootstrapImage
my $VERBOSE = '';
if ( $CONFIG{'verbose'} )
{
$VERBOSE = "--verbose";
$VERBOSE = "--verbose";
}
#
@@ -415,10 +415,10 @@ sub installDebootstrapImage
#
if ( $CONFIG{'cache'} eq "yes" )
{
print "\nCopying files from new installation to host.\n";
copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives",
"/var/cache/apt/archives" );
print( "Done\n" );
print "\nCopying files from new installation to host.\n";
copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives",
"/var/cache/apt/archives" );
print( "Done\n" );
}
@@ -440,8 +440,8 @@ sub installRPMStrapImage
#
if ( ! -x '/usr/bin/rpmstrap' )
{
print "You've chosen to use the rpmstrap program, but it isn't installed.\n";
exit;
print "You've chosen to use the rpmstrap program, but it isn't installed.\n";
exit;
}
#
@@ -450,7 +450,7 @@ sub installRPMStrapImage
my $VERBOSE='';
if ( $CONFIG{'verbose'} )
{
$VERBOSE .= "--verbose";
$VERBOSE .= "--verbose";
}
#
@@ -485,14 +485,14 @@ sub runCommand
#
if ( $CONFIG{'verbose'} )
{
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
#
# Copy stderr to stdout, so we can see it.
#
$cmd .= " 2>&1";
}
else
{
$cmd .= " >/dev/null 2>/dev/null" ;
$cmd .= " >/dev/null 2>/dev/null" ;
}
@@ -503,9 +503,9 @@ sub runCommand
if ( $? != 0 )
{
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
print "Running command '$cmd' failed.\n";
print "Aborting\n";
exit;
}
@@ -541,19 +541,19 @@ sub copyDebFiles
#
foreach my $file ( sort ( glob( $source . "/*.deb" ) ) )
{
my $name = $file;
if ( $name =~ /(.*)\/(.*)/ )
{
$name = $2;
}
my $name = $file;
if ( $name =~ /(.*)\/(.*)/ )
{
$name = $2;
}
#
# Only copy if the file doesn't already exist.
#
if ( ! ( -e $dest . "/" . $name ) )
{
File::Copy::cp( $file, $dest );
}
#
# Only copy if the file doesn't already exist.
#
if ( ! ( -e $dest . "/" . $name ) )
{
File::Copy::cp( $file, $dest );
}
}
print "Done\n";

View File

@@ -55,24 +55,23 @@ E_O_STATIC
while [ "${count}" -le "${ip_count}" ]; do
value=\$ip${count}
value=`eval echo $value`
value=\$ip${count}
value=`eval echo $value`
logMessage Adding etho:${interface}
logMessage Adding etho:${interface}
cat <<E_O_STATIC >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface}
cat <<E_O_STATIC >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface}
DEVICE=eth0:${interface}
ONBOOT=yes
BOOTPROTO=static
IPADDR=${value}
NETMASK=${netmask}
E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
count=`expr $count + 1`
interface=`expr $interface + 1`
done
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp

View File

@@ -62,25 +62,24 @@ if [[ -z "${dhcp}" ]]; then
else
logMessage Adding ${hostname} to /etc/hosts on the host
logMessage Adding ${hostname} to /etc/hosts on the host
echo "${ip1} ${hostname}" >> /etc/hosts
echo "${ip1} ${hostname}" >> /etc/hosts
#
# If we've updated the /etc/hosts file on the host machine
# and there is an installation of dnsmasq installed then
# reload it.
#
# This will let the local LAN clients lookup the new address.
#
if [ -x /usr/sbin/dnsmasq ] ; then
if [ -e /var/run/dnsmasq.pid ]; then
#
# If we've updated the /etc/hosts file on the host machine
# and there is an installation of dnsmasq installed then
# reload it.
#
# This will let the local LAN clients lookup the new address.
#
if [ -x /usr/sbin/dnsmasq ] ; then
if [ -e /var/run/dnsmasq.pid ]; then
logMessage Allowing DNSMasq to restart.
kill -HUP `cat /var/run/dnsmasq.pid`
fi
fi
logMessage Allowing DNSMasq to restart.
kill -HUP `cat /var/run/dnsmasq.pid`
fi
fi
fi
fi

View File

@@ -36,7 +36,7 @@ my @files = ( "/etc/hosts",
"/etc/resolv.conf",
"/etc/gshadow",
"/etc/group"
);
);
foreach my $file ( @files )
{
@@ -81,19 +81,19 @@ if ( ! $ENV{'passwd'} )
foreach my $line ( <ORIG> )
{
chomp( $line );
if ( $line =~ /^([^:]+):([^:]+):([^:]+)/ )
{
my $user = $1;
my $pass = $2;
my $uid = $3;
chomp( $line );
if ( $line =~ /^([^:]+):([^:]+):([^:]+)/ )
{
my $user = $1;
my $pass = $2;
my $uid = $3;
if ( ( $uid >= 1000 ) &&
( $user ne "nobody" ) )
{
print NEW $line . "\n";
}
}
if ( ( $uid >= 1000 ) &&
( $user ne "nobody" ) )
{
print NEW $line . "\n";
}
}
}
close( NEW );

View File

@@ -38,8 +38,8 @@ options="errors=remount-ro"
case "${fs}" in
xfs)
options="defaults"
;;
options="defaults"
;;
esac
logMessage Filesystem options are ${options}
@@ -69,11 +69,11 @@ E_O_FSTAB
#
#case "${fs}" in
# xfs)
# install_package xfsprogs
# ;;
# install_package xfsprogs
# ;;
# reiserfs)
# install_package reiserfsprogs
# ;;
# install_package reiserfsprogs
# ;;
#esac

View File

@@ -36,8 +36,8 @@ mkdir ${prefix}/lib/tls
#
case "${dist}" in
etch|sid)
installDebianPackage ${prefix} libc6-xen
;;
installDebianPackage ${prefix} libc6-xen
;;
esac

View File

@@ -45,7 +45,7 @@ function setupDynamicNetworking
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
@@ -75,7 +75,7 @@ function setupStaticNetworking
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
@@ -94,21 +94,21 @@ E_O_STATIC
count=2
while [ "${count}" -le "${ip_count}" ]; do
value=\$ip${count}
value=`eval echo $value`
logMessage Adding etho:${interface}
value=\$ip${count}
value=`eval echo $value`
cat <<E_O_STATIC >>${prefix}/etc/network/interfaces
logMessage Adding etho:${interface}
cat <<E_O_STATIC >>${prefix}/etc/network/interfaces
auto eth0:${interface}
iface eth0:${interface} inet static
address ${value}
netmask ${netmask}
# post-up ethtool -K eth0 tx off
E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
count=`expr $count + 1`
interface=`expr $interface + 1`
done
}

View File

@@ -62,25 +62,25 @@ if [[ -z "${dhcp}" ]]; then
else
logMessage Adding ${hostname} to /etc/hosts on the host
logMessage Adding ${hostname} to /etc/hosts on the host
echo "${ip1} ${hostname}" >> /etc/hosts
echo "${ip1} ${hostname}" >> /etc/hosts
#
# If we've updated the /etc/hosts file on the host machine
# and there is an installation of dnsmasq installed then
# reload it.
#
# This will let the local LAN clients lookup the new address.
#
if [ -x /usr/sbin/dnsmasq ] ; then
if [ -e /var/run/dnsmasq.pid ]; then
#
# If we've updated the /etc/hosts file on the host machine
# and there is an installation of dnsmasq installed then
# reload it.
#
# This will let the local LAN clients lookup the new address.
#
if [ -x /usr/sbin/dnsmasq ] ; then
if [ -e /var/run/dnsmasq.pid ]; then
logMessage Allowing DNSMasq to restart.
logMessage Allowing DNSMasq to restart.
kill -HUP `cat /var/run/dnsmasq.pid`
fi
fi
kill -HUP `cat /var/run/dnsmasq.pid`
fi
fi
fi
fi

View File

@@ -36,7 +36,7 @@ my @files = ( "/etc/hosts",
"/etc/resolv.conf",
"/etc/gshadow",
"/etc/group"
);
);
foreach my $file ( @files )
{
@@ -81,19 +81,19 @@ if ( ! $ENV{'passwd'} )
foreach my $line ( <ORIG> )
{
chomp( $line );
if ( $line =~ /^([^:]+):([^:]+):([^:]+)/ )
{
my $user = $1;
my $pass = $2;
my $uid = $3;
chomp( $line );
if ( $line =~ /^([^:]+):([^:]+):([^:]+)/ )
{
my $user = $1;
my $pass = $2;
my $uid = $3;
if ( ( $uid >= 1000 ) &&
( $user ne "nobody" ) )
{
print NEW $line . "\n";
}
}
if ( ( $uid >= 1000 ) &&
( $user ne "nobody" ) )
{
print NEW $line . "\n";
}
}
}
close( NEW );

View File

@@ -38,8 +38,8 @@ options="errors=remount-ro"
case "${fs}" in
xfs)
options="defaults"
;;
options="defaults"
;;
esac
@@ -67,11 +67,11 @@ E_O_FSTAB
#
case "${fs}" in
xfs)
installDebianPackage ${prefix} xfsprogs
;;
installDebianPackage ${prefix} xfsprogs
;;
reiserfs)
installDebianPackage ${prefix} reiserfsprogs
;;
installDebianPackage ${prefix} reiserfsprogs
;;
esac