From 2bb8a1b394df128d1b20ddae487f0f9f26b69943 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 13 Jun 2006 13:21:23 +0000 Subject: [PATCH] 2006-06-13 13:21:22 by steve TABs become spaces. Tabs are evil. --- bin/xen-create-image | 346 +++++++++++++++--------------- bin/xen-delete-image | 224 +++++++++---------- bin/xen-duplicate-image | 164 +++++++------- bin/xen-list-images | 178 +++++++-------- bin/xen-update-image | 112 +++++----- bin/xt-create-xen-config | 54 ++--- bin/xt-customize-image | 128 +++++------ bin/xt-install-image | 160 +++++++------- hooks/centos4/40-setup-networking | 13 +- hooks/centos4/50-setup-hostname | 31 ++- hooks/centos4/60-copy-host-files | 26 +-- hooks/centos4/90-make-fstab | 12 +- hooks/debian/10-disable-tls | 4 +- hooks/debian/40-setup-networking | 18 +- hooks/debian/50-setup-hostname | 30 +-- hooks/debian/60-copy-host-files | 26 +-- hooks/debian/90-make-fstab | 12 +- 17 files changed, 768 insertions(+), 770 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 73b0540..97dfda3 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -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 = ) ) { chomp $line; - if ($line =~ s/\\$//) - { - $line .= ; - redo unless eof(FILE); - } + if ($line =~ s/\\$//) + { + $line .= ; + 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 <) ) { chomp $line; - if ($line =~ s/\\$//) - { - $line .= ; - redo unless eof(FILE); - } + if ($line =~ s/\\$//) + { + $line .= ; + 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; } diff --git a/bin/xen-duplicate-image b/bin/xen-duplicate-image index 7c52611..521e9fb 100755 --- a/bin/xen-duplicate-image +++ b/bin/xen-duplicate-image @@ -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 = ) ) { chomp $line; - if ($line =~ s/\\$//) - { - $line .= ; - redo unless eof(FILE); - } + if ($line =~ s/\\$//) + { + $line .= ; + 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<) ) { chomp $line; - if ($line =~ s/\\$//) - { - $line .= ; - redo unless eof(FILE); - } + if ($line =~ s/\\$//) + { + $line .= ; + 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 ( ) { - 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 ( ) { - 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"; } diff --git a/bin/xen-update-image b/bin/xen-update-image index 75dc2de..d808624 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -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 = ) ) { chomp $line; - if ($line =~ s/\\$//) - { - $line .= ; - redo unless eof(FILE); - } + if ($line =~ s/\\$//) + { + $line .= ; + 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; } } diff --git a/bin/xt-create-xen-config b/bin/xt-create-xen-config index ef6dbaf..9b8de16 100755 --- a/bin/xt-create-xen-config +++ b/bin/xt-create-xen-config @@ -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 =< 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 < 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 < 1 ) { - print <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface} + cat <${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 <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp diff --git a/hooks/centos4/50-setup-hostname b/hooks/centos4/50-setup-hostname index 97d6384..fd324bb 100755 --- a/hooks/centos4/50-setup-hostname +++ b/hooks/centos4/50-setup-hostname @@ -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 diff --git a/hooks/centos4/60-copy-host-files b/hooks/centos4/60-copy-host-files index 1bd59d3..a4ffb3c 100755 --- a/hooks/centos4/60-copy-host-files +++ b/hooks/centos4/60-copy-host-files @@ -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 ( ) { - 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 ); diff --git a/hooks/centos4/90-make-fstab b/hooks/centos4/90-make-fstab index bc5b6f1..31b2747 100755 --- a/hooks/centos4/90-make-fstab +++ b/hooks/centos4/90-make-fstab @@ -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 diff --git a/hooks/debian/10-disable-tls b/hooks/debian/10-disable-tls index 01023a1..ab8b352 100755 --- a/hooks/debian/10-disable-tls +++ b/hooks/debian/10-disable-tls @@ -36,8 +36,8 @@ mkdir ${prefix}/lib/tls # case "${dist}" in etch|sid) - installDebianPackage ${prefix} libc6-xen - ;; + installDebianPackage ${prefix} libc6-xen + ;; esac diff --git a/hooks/debian/40-setup-networking b/hooks/debian/40-setup-networking index 88ae6ac..05bbd48 100755 --- a/hooks/debian/40-setup-networking +++ b/hooks/debian/40-setup-networking @@ -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 <>${prefix}/etc/network/interfaces + logMessage Adding etho:${interface} + + cat <>${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 } diff --git a/hooks/debian/50-setup-hostname b/hooks/debian/50-setup-hostname index 97d6384..5f6a4fd 100755 --- a/hooks/debian/50-setup-hostname +++ b/hooks/debian/50-setup-hostname @@ -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 diff --git a/hooks/debian/60-copy-host-files b/hooks/debian/60-copy-host-files index d7ba682..0a390eb 100755 --- a/hooks/debian/60-copy-host-files +++ b/hooks/debian/60-copy-host-files @@ -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 ( ) { - 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 ); diff --git a/hooks/debian/90-make-fstab b/hooks/debian/90-make-fstab index 9c5689a..d6dab2f 100755 --- a/hooks/debian/90-make-fstab +++ b/hooks/debian/90-make-fstab @@ -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