MYDan
view release on metacpan or search on metacpan
dan/agent/argv/mrsync view on Meta::CPAN
#!# perl: agent/argv/mrsync
use strict;
use warnings;
use Cwd;
use Getopt::Long;
use MYDan::Agent::Mrsync;
return sub
{
local $/;
my ( %o, $data );
unless( defined $_[0] ) { shift; %o = @_; }
else
{
Getopt::Long::GetOptionsFromArray( \@_, \%o,
qw( src=s dst=s sp=s dp=s timeout=i max=i retry=i nice=i user=s sudo=s gave=i chown=s chmod=s cc env )
);
}
$o{retry} = 2 unless defined $o{retry};
$o{timeout} = 300 unless defined $o{timeout};
$o{gave} = 3 unless defined $o{gave};
$o{user} = `id -un` and chop $o{user} unless $o{user};
my $option = MYDan::Util::OptConf->load();
my $range = MYDan::Node->new( $option->dump( 'range' ) );
map{ $o{$_} = [ $range->load( $o{$_} )->list ] if $o{$_} && ! ref $o{$_} }qw( src dst );
my %agent = $option->dump( 'agent' );
my $isc = $agent{role} && $agent{role} eq 'client' ? 1 : 0;
my %p = map{ $o{$_} => 1 }grep{ defined $o{$_} }qw( sp dp );
my %n = map{ $_ => 1 }@{$o{src}}, @{$o{dst}};
$o{queryxdata} = MYDan::Agent::Mrsync::queryx( node => [ keys %n ], map{ $_ => $o{$_} }qw( user sudo env ) );
map{ die "agent/argv/mrsync: $_ null" unless $o{$_} && @{$o{$_}} }qw( src dst );
die "agent/argv/mrsync: sp undef" unless $o{sp};
return \%o;
};
( run in 0.506 second using v1.01-cache-2.11-cpan-71847e10f99 )