line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# client::rsync Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Client::Rsync; |
7
|
1
|
|
|
1
|
|
1177
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
369
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable network) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
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
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
my ($source, $destination, $ssh_port, $args) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
0
|
|
|
|
$ssh_port ||= $self->ssh_port; |
50
|
0
|
|
0
|
|
|
|
$args ||= $self->args; |
51
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('sync', $source) or return; |
52
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('sync', $destination) or return; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $use_ssh = $self->use_ssh; |
55
|
0
|
|
|
|
|
|
my $ssh_args = $self->ssh_args; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $cmd = 'rsync'; |
58
|
0
|
0
|
|
|
|
|
if ($use_ssh) { |
59
|
0
|
|
|
|
|
|
$cmd .= " -e \"ssh -p $ssh_port $ssh_args\" $args $source $destination"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
|
$cmd .= " $args $source $destination"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self->capture($cmd); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |