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 | |
parent | b601b4d782b7cbc2583461a4d3aad00499fc7aa8 (diff) | |
download | vyatta-op-4d8f17decb63d04ca9d478381e4a94b17333b1d0.tar.gz vyatta-op-4d8f17decb63d04ca9d478381e4a94b17333b1d0.zip |
Add options when copying a directory to another directory
-rwxr-xr-x | scripts/vyatta-image-tools.pl | 21 | ||||
-rw-r--r-- | templates/copy/files/node.tag/node.def | 5 | ||||
-rw-r--r-- | templates/copy/files/node.tag/to/node.tag/node.def | 5 |
3 files changed, 28 insertions, 3 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); diff --git a/templates/copy/files/node.tag/node.def b/templates/copy/files/node.tag/node.def index 8df0e7c..c52dccd 100644 --- a/templates/copy/files/node.tag/node.def +++ b/templates/copy/files/node.tag/node.def @@ -1,3 +1,6 @@ -help: Directory to copy files from +help: Copy files from specified source + scp://<user>:<passwd>@<host>/<file> + ftp://<user>:<passwd>@<host>/<file> + tftp://<host>/<file> comptype: imagefiles allowed: echo -n "<imagefiles>" diff --git a/templates/copy/files/node.tag/to/node.tag/node.def b/templates/copy/files/node.tag/to/node.tag/node.def index 751783b..75d4aff 100644 --- a/templates/copy/files/node.tag/to/node.tag/node.def +++ b/templates/copy/files/node.tag/to/node.tag/node.def @@ -1,4 +1,7 @@ -help: Directory to copy files to +help: Copy files to specified destination + scp://<user>:<passwd>@<host>/<file> + ftp://<user>:<passwd>@<host>/<file> + tftp://<host>/<file> comptype: imagefiles allowed: echo -n "<imagefiles>" run: sudo ${vyatta_sbindir}/vyatta-image-tools.pl --copy $3 $5 |