diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-04-25 18:54:52 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-04-25 18:54:52 -0500 |
commit | 4d8f17decb63d04ca9d478381e4a94b17333b1d0 (patch) | |
tree | b863493605e1dd01af9e9d1d6f4e601692e90fb7 /scripts | |
parent | b601b4d782b7cbc2583461a4d3aad00499fc7aa8 (diff) | |
download | vyatta-op-4d8f17decb63d04ca9d478381e4a94b17333b1d0.tar.gz vyatta-op-4d8f17decb63d04ca9d478381e4a94b17333b1d0.zip |
Add options when copying a directory to another directory
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-image-tools.pl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl index 0adc1f0..b343214 100755 --- a/scripts/vyatta-image-tools.pl +++ b/scripts/vyatta-image-tools.pl @@ -112,6 +112,11 @@ sub url_copy { $from =~ /.*\/(.*)/; my $from_file = $1; $to = "$to/$from_file"; + if (-f "$to") { + if (!y_or_n("This file exists; overwrite if needed?")){ + exit 0; + } + } } curl_from($from, $to); } @@ -141,8 +146,22 @@ sub copy { } elsif ( -d $to && -d $from ){ my $print_from = conv_file_to_rel($f_topdir, $from); my $print_to = conv_file_to_rel($t_topdir, $to); - if (y_or_n("Merge directory $print_from with $print_to?")){ + print "Directory exists. Would you like to:\n" + ." Merge (M)\n" + ." Overwrite (O)\n" + ." Create subdirectory (S): "; + my $answer = <>; + if ($answer =~ /M|m/){ rsync($from, $to); + } elsif ($answer =~ /O|o/){ + system("rm -rf $to"); + rsync($from, $to); + } elsif ($answer =~ /S|s/){ + $from =~ /.*\/(.*?)\//; + my $from_lastdir = $1; + copy($from, "$to/$from_lastdir"); + } else { + print "Unsupported operation\n"; } } else { rsync($from, $to); |