From 5c95dec3dfa97a50b7f121d3d06c259bd25f8e52 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 18 Dec 2005 19:11:28 +0000 Subject: [PATCH] 2005-12-18 19:11:28 by steve $DIR is no more. All configuration is now centralised and unified. --- etc/xen-tools.conf | 3 ++- xen-create-image | 43 +++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/etc/xen-tools.conf b/etc/xen-tools.conf index 5c1c9c1..921e3db 100644 --- a/etc/xen-tools.conf +++ b/etc/xen-tools.conf @@ -11,7 +11,7 @@ # --fs=ext3 becomes 'fs=ext3'. # # -# $Id: xen-tools.conf,v 1.3 2005-12-18 16:32:32 steve Exp $ +# $Id: xen-tools.conf,v 1.4 2005-12-18 19:11:28 steve Exp $ # @@ -26,3 +26,4 @@ gateway=192.168.1.1 netmask=255.255.255.0 +dir = /home/xen \ No newline at end of file diff --git a/xen-create-image b/xen-create-image index 3c3d4b9..df4489e 100755 --- a/xen-create-image +++ b/xen-create-image @@ -187,7 +187,7 @@ broadcast = 255.255.255.0 -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.17 2005-12-18 19:07:19 steve Exp $ + $Id: xen-create-image,v 1.18 2005-12-18 19:11:28 steve Exp $ =cut @@ -217,17 +217,14 @@ use Pod::Usage; # -# Configuration options. +# Configuration options, initially read from the configuration files +# but may be overridden by the command line. +# +# Command line flags *always* take precedence over the configuration files(s). # my %CONFIG; -# -# Options set on the command line. -# -my $DIR; # Mandatory. - - # @@ -312,15 +309,15 @@ print "---\n"; # # If the output directories don't exist then create them. # -if ( ! -d $DIR . "/domains/" ) +if ( ! -d $CONFIG{'dir'} . "/domains/" ) { - mkdir $DIR . '/domains', 0777 - || die "Cannot create $DIR/domains - $!"; + mkdir $CONFIG{'dir'} . '/domains', 0777 + || die "Cannot create $CONFIG{'dir'}/domains - $!"; } -if ( ! -d $DIR . "/domains/" . $CONFIG{'hostname'} ) +if ( ! -d $CONFIG{'dir'} . "/domains/" . $CONFIG{'hostname'} ) { - mkdir $DIR. '/domains/' . $CONFIG{'hostname'}, 0777 - || die "Cannot create $DIR/domains/$CONFIG{'hostname'} - $!" ; + mkdir $CONFIG{'dir'}. '/domains/' . $CONFIG{'hostname'}, 0777 + || die "Cannot create $CONFIG{'dir'}/domains/$CONFIG{'hostname'} - $!" ; } @@ -328,8 +325,8 @@ if ( ! -d $DIR . "/domains/" . $CONFIG{'hostname'} ) # # The two images we'll use, one for the disk image, one for swap. # -my $image = $DIR . '/domains/' . $CONFIG{'hostname'} . "/disk.img" ; -my $swap = $DIR . '/domains/' . $CONFIG{'hostname'} . "/swap.img" ; +my $image = $CONFIG{'dir'} . '/domains/' . $CONFIG{'hostname'} . "/disk.img" ; +my $swap = $CONFIG{'dir'} . '/domains/' . $CONFIG{'hostname'} . "/swap.img" ; # # Create swapfile and initialise it. @@ -611,7 +608,7 @@ sub parseCommandLineArguments "mask=s", \$CONFIG{'netmask'}, "broadcast=s",\$CONFIG{'broadcast'}, "network=s", \$CONFIG{'network'}, - "dir=s", \$DIR, + "dir=s", \$CONFIG{'dir'}, "dhcp", \$CONFIG{'dhcp'}, "mirror=s", \$CONFIG{'mirror'}, "size=s", \$CONFIG{'size'}, @@ -651,7 +648,7 @@ EOF } - if (!defined( $DIR ) ) + if (!defined( $CONFIG{'dir'} ) ) { print<