Client/Rsync.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Client/Rest.pm ↑ Summary Client/Smbclient.pm »
1 #
2 # $Id$
3 #
4 # client::rsync Brik
5 #
6 package Metabrik::Client::Rsync;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Shell::Command);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable network) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 commands => {
19 sync => [ qw(source destination ssh_port|OPTIONAL args|OPTIONAL) ],
20 },
21 attributes => {
22 use_ssh => [ qw(0|1) ],
23 ssh_port => [ qw(port) ],
24 ssh_args => [ qw(args) ],
25 args => [ qw(args) ],
26 },
27 attributes_default => {
28 use_ssh => 1,
29 ssh_port => 22,
30 ssh_args => '',
31 args => '-azv',
32 capture_stderr => 1,
33 },
34 need_packages => {
35 ubuntu => [ qw(rsync) ],
36 debian => [ qw(rsync) ],
37 kali => [ qw(rsync) ],
38 },
39 require_binaries => {
40 rsync => [ ],
41 },
42 };
43 }
44  
45 sub sync {
46 my $self = shift;
47 my ($source, $destination, $ssh_port, $args) = @_;
48  
49 $ssh_port ||= $self->ssh_port;
50 $args ||= $self->args;
51 $self->brik_help_run_undef_arg('sync', $source) or return;
52 $self->brik_help_run_undef_arg('sync', $destination) or return;
53  
54 my $use_ssh = $self->use_ssh;
55 my $ssh_args = $self->ssh_args;
56  
57 my $cmd = 'rsync';
58 if ($use_ssh) {
59 $cmd .= " -e \"ssh -p $ssh_port $ssh_args\" $args $source $destination";
60 }
61 else {
62 $cmd .= " $args $source $destination";
63 }
64  
65 return $self->capture($cmd);
66 }
67  
68 1;
69  
70 __END__
« Client/Rest.pm ↑ Summary Client/Smbclient.pm »