From fc797786504794575c0a30022e87fea798f6aed3 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 1 Jan 2006 14:28:32 +0000 Subject: [PATCH] 2006-01-01 14:28:32 by steve Minor comment tweaks. --- xen-create-image | 89 ++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/xen-create-image b/xen-create-image index 8b69fe4..2cece7c 100755 --- a/xen-create-image +++ b/xen-create-image @@ -249,8 +249,8 @@ Show the version number and exit. xen-create-image --debootstrap='--include=screen,sudo,less' An alternative is to use the hook directory, described below, to - run a script which will install new packages upon the system for - you. + run a script which will install new packages upon each virtual + image you create. =head1 HOOKS @@ -288,10 +288,9 @@ Show the version number and exit. =for example cut - The hook scripts are used extensively by the xen-create-image - tool to setup the base system. If you're looking at extending the - processing of the images it is recommended you examine the default - hooks. + The hook scripts are used extensively by this script to setup the + base system. If you're looking at extending the processing of new + images it is recommended you examine the default hooks. =cut @@ -303,7 +302,7 @@ Show the version number and exit. -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.74 2005-12-26 15:27:59 steve Exp $ + $Id: xen-create-image,v 1.75 2006-01-01 14:28:32 steve Exp $ =cut @@ -420,8 +419,12 @@ $CONFIG{'kernel'} = '/boot/vmlinuz-2.6.12-xenU'; $CONFIG{'debootstrap'} = ''; $CONFIG{'hook_dir'} = '/etc/xen-tools/xen-create-image.d/'; + + + + # -# Read configuration file(s) if they exist. +# Read the global configuration file if it exists. # if ( -e "/etc/xen-tools/xen-tools.conf" ) { @@ -430,7 +433,7 @@ if ( -e "/etc/xen-tools/xen-tools.conf" ) # -# Parse command line arguments, these override the values from the +# Parse command line arguments. These override the values from the # configuration file. # parseCommandLineArguments(); @@ -443,13 +446,17 @@ parseCommandLineArguments(); checkArguments(); +# +# Avoid non-root users after this point. We allowed them up till +# now so they could read the manual, see help/version info, etc. +# if ( $EFFECTIVE_USER_ID != 0 ) { print < Mb + # + # Convert Gb -> Mb for the disk image size, and swap size. + # if ( $CONFIG{'size'} =~ /^(\d+)Gb*$/i ) { $CONFIG{'size'} = $1 * 1024 . "M"; @@ -985,12 +989,27 @@ EOF $CONFIG{'swap'} = $1 * 1024 . "M"; } + # # Strip trailing Mb from the memory size. + # if ( $CONFIG{'memory'} =~ /^(\d+)Mb*$/i ) { $CONFIG{'memory'} = $1; } + # + # Convert the image size to k. + # + $CONFIG{'size'} =~ s/Mb*$/k/i; + + # + # Now strip the trailing 'Mb' from the swap size. + # + if ( $CONFIG{'swap'} =~ /^(\d+)Mb*$/i ) + { + $CONFIG{'swap'} = $1; + } + # # Check mirror format @@ -1174,7 +1193,7 @@ sub runCommandWithProgress Find and return the width of the current terminal. This makes use of the optional Term::Size module. If it isn't installed then - we fall back to using 80. + we fall back to the standard size of 80x25. =cut @@ -1188,9 +1207,8 @@ sub getTerminalSize my $height = 25; # - # Test loading the Cache module, if it fails then - # the cache isn't enabled regardless of what the - # configuration file says. + # Test loading the size module. If this fails + # then we will use the defaults sizes. # eval( $testModule ); if ( $@ ) @@ -1198,6 +1216,10 @@ sub getTerminalSize } else { + # + # Term::Size is available, so use it to find + # the current terminal size. + # ($width, $height ) = Term::Size::chars(); } @@ -1209,16 +1231,17 @@ sub getTerminalSize =head2 runHooks When the image has been created, but before the temporary image - is unmounted each executable script inside the hook directory will - be executed. (The scripts are executed "in order" which might - be useful for users who wish to ensure some actions occur before - others.) + is unmounted, each executable script inside the hook directory will + be executed. + + (The scripts are executed "in order" which might be useful for users + who wish to ensure some actions occur before others.) The scripts will be given single argument: the name of the directory within which the image is mounted. - (The rest of the configuration variables will be passed via - environmental variables.) + The rest of the configuration variables will be passed via + environmental variables. =cut