From 32da3dd94eb5e29fb8228163970fd7c8ddf20c7b Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 9 Jun 2006 14:55:08 +0000 Subject: [PATCH] 2006-06-09 14:55:08 by steve Added missing commmand line arguments. Added summery of the action we're going to conduct. --- bin/xen-create-image | 126 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 113 insertions(+), 13 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 5be624d..6ebc937 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -31,7 +31,7 @@ xen-create-image - Create a new Xen instance -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.4 2006-06-09 14:48:29 steve Exp $ + $Id: xen-create-image,v 1.5 2006-06-09 14:55:08 steve Exp $ =cut @@ -49,6 +49,7 @@ The LICENSE file contains the full text of the license. use strict; +use English; use Env; use Getopt::Long; use Pod::Usage; @@ -88,12 +89,26 @@ setupDefaultOptions(); parseCommandLineArguments(); +# +# Ensure we're started by root at this point. This is required +# to make sure we can create new LVM volumes, or mount loopback images. +# +testRootUser(); + + # # Check our arguments # checkArguments(); +# +# Show a summery of what we're going to do. +# +showSummery(); + + + # # Create and mount the images if we're using loopback filesystems. # @@ -231,21 +246,36 @@ sub parseCommandLineArguments "dist=s", \$CONFIG{'dist'}, # Locations - "dir=s", \$CONFIG{'dir'}, - "lvm=s", \$CONFIG{'lvm'}, + "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'}, # Exclusive - "copy=s", \$CONFIG{'rpmstrap'}, - "debootstrap", \$CONFIG{'debootstrap'}, - "rpmstrap", \$CONFIG{'rpmstrap'}, - "tar=s", \$CONFIG{'tar'}, + "copy=s", \$CONFIG{'rpmstrap'}, + "debootstrap", \$CONFIG{'debootstrap'}, + "rpmstrap", \$CONFIG{'rpmstrap'}, + "tar=s", \$CONFIG{'tar'}, + + # Misc. options + "boot", \$CONFIG{'boot'}, + "cache=s", \$CONFIG{'cache'}, + "ide", \$CONFIG{'ide'}, + "passwd", \$CONFIG{'passwd'}, # Help options - "verbose", \$CONFIG{'verbose'}, - "debug", \$CONFIG{'verbose'}, - "help", \$HELP, - "manual", \$MANUAL, - "version", \$VERSION + "debug", \$CONFIG{'verbose'}, + "help", \$HELP, + "manual", \$MANUAL, + "verbose", \$CONFIG{'verbose'}, + "version", \$VERSION ); pod2usage(1) if $HELP; @@ -254,7 +284,7 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.4 $'; + my $REVISION = '$Revision: 1.5 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { @@ -268,6 +298,30 @@ sub parseCommandLineArguments } +=head2 testRootUser + + Make sure this script is being run by a user with UID 0. + +=cut + +sub testRootUser +{ + if ( $EFFECTIVE_USER_ID != 0 ) + { + print <