From 1b6d3dbdeb9326b8fcff1ee594e10fdfb21a43aa Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sun, 23 Nov 2008 21:12:36 +0000 Subject: [PATCH] Delete the file if it exists --- bin/xen-create-image | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 69e477c..d9f640d 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -1812,11 +1812,19 @@ EOF # my $cfg = $CONFIG{'output'} . "/" . $CONFIG{'hostname'} . $CONFIG{'extension'}; - if ( ( -e $cfg ) && ( !$CONFIG{'force'} ) ) + if ( -e $cfg ) { - print "Configuration file already exists; $cfg\n"; - print "Aborting\n"; - exit 127; + if ( $CONFIG{'force'} ) + { + $CONFIG{'verbose'} && print "Removing existing file: $cfg\n"; + unlink( $cfg ); + } + else + { + print "Configuration file already exists; $cfg\n"; + print "Aborting\n"; + exit 127; + } } }