diff --git a/bin/xen-delete-image b/bin/xen-delete-image index 173969c..31c1935 100755 --- a/bin/xen-delete-image +++ b/bin/xen-delete-image @@ -269,13 +269,25 @@ sub parseCommandLineArguments my $VERSION = 0; $CONFIG{ 'dry-run' } = 0; + # + # We record the installation method here because we want + # to ensure that we allow the method supplied upon the command line + # to overwrite the one we might have ready read from the configuration + # file. + # + my %install; + $install{ 'evms' } = undef; + $install{ 'dir' } = undef; + $install{ 'lvm' } = undef; + $install{ 'zpool' } = undef; + # Parse options. # - GetOptions( "dir=s", \$CONFIG{ 'dir' }, + GetOptions( "dir=s", \$install{ 'dir' }, "dry-run", \$CONFIG{ 'dry-run' }, - "lvm=s", \$CONFIG{ 'lvm' }, - "evms=s", \$CONFIG{ 'evms' }, - "zpool=s", \$CONFIG{ 'zpool' }, + "lvm=s", \$install{ 'lvm' }, + "evms=s", \$install{ 'evms' }, + "zpool=s", \$install{ 'zpool' }, "extension:s", \$CONFIG{ 'extension' }, "hostname=s@", \$CONFIG{ 'hostname' }, "test", \$CONFIG{ 'test' }, @@ -286,6 +298,39 @@ sub parseCommandLineArguments "version", \$VERSION ); + # + # Now make ensure that the command line setting of '--lvm', '--evms', '--zpool' + # and '--dir=x' override anything specified in the configuration file. + # + if ( $install{ 'dir' } ) + { + $CONFIG{ 'dir' } = $install{ 'dir' }; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'zpool' } = undef; + } + if ( $install{ 'evms' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'evms' } = $install{ 'evms' }; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'zpool' } = undef; + } + if ( $install{ 'lvm' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = $install{ 'lvm' }; + $CONFIG{ 'zpool' } = undef; + } + if ( $install{ 'zpool' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'zpool' } = $install{ 'zpool' }; + } + pod2usage(1) if $HELP; pod2usage( -verbose => 2 ) if $MANUAL; diff --git a/bin/xen-update-image b/bin/xen-update-image index fce7218..c6b5934 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -344,15 +344,52 @@ sub parseCommandLineArguments my $MANUAL = 0; my $VERSION = 0; + # + # We record the installation method here because we want + # to ensure that we allow the method supplied upon the command line + # to overwrite the one we might have ready read from the configuration + # file. + # + my %install; + $install{ 'evms' } = undef; + $install{ 'dir' } = undef; + $install{ 'lvm' } = undef; + # Parse options. # - GetOptions( "dir=s", \$CONFIG{ 'dir' }, - "lvm=s", \$CONFIG{ 'lvm' }, - "evms=s", \$CONFIG{ 'evms' }, + GetOptions( "dir=s", \$install{ 'dir' }, + "lvm=s", \$install{ 'lvm' }, + "evms=s", \$install{ 'evms' }, "help", \$HELP, "manual", \$MANUAL, "version", \$VERSION ); + # + # Now make ensure that the command line setting of '--lvm', '--evms', '--zpool' + # and '--dir=x' override anything specified in the configuration file. + # + if ( $install{ 'dir' } ) + { + $CONFIG{ 'dir' } = $install{ 'dir' }; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'zpool' } = undef; + } + if ( $install{ 'evms' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'evms' } = $install{ 'evms' }; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'zpool' } = undef; + } + if ( $install{ 'lvm' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = $install{ 'lvm' }; + $CONFIG{ 'zpool' } = undef; + } + pod2usage(1) if $HELP; pod2usage( -verbose => 2 ) if $MANUAL;