mirror of https://github.com/jimsalterjrs/sanoid
fixed use of uninitialized value warnings in syncoid
This commit is contained in:
parent
adb14d2343
commit
2876637655
31
syncoid
31
syncoid
|
|
@ -7,6 +7,7 @@
|
||||||
my $version = '1.4.7';
|
my $version = '1.4.7';
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use warnings;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Time::Local;
|
use Time::Local;
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
|
|
@ -333,12 +334,14 @@ sub getargs {
|
||||||
|
|
||||||
if ($args{'r'}) { $args{'recursive'} = $args{'r'}; }
|
if ($args{'r'}) { $args{'recursive'} = $args{'r'}; }
|
||||||
|
|
||||||
|
if (!defined $args{'compress'}) { $args{'compress'} = 'default'; }
|
||||||
|
|
||||||
if ($args{'compress'} eq 'gzip') {
|
if ($args{'compress'} eq 'gzip') {
|
||||||
$args{'rawcompresscmd'} = '/bin/gzip';
|
$args{'rawcompresscmd'} = '/bin/gzip';
|
||||||
$args{'compressargs'} = '-3';
|
$args{'compressargs'} = '-3';
|
||||||
$args{'rawdecompresscmd'} = '/bin/zcat';
|
$args{'rawdecompresscmd'} = '/bin/zcat';
|
||||||
$args{'decompressargs'} = '';
|
$args{'decompressargs'} = '';
|
||||||
} elsif ( ($args{'compress'} eq 'lzo') || ! (defined $args{'compress'}) ) {
|
} elsif ( ($args{'compress'} eq 'lzo') || ($args{'compress'} eq 'default') ) {
|
||||||
$args{'rawcompresscmd'} = '/usr/bin/lzop';
|
$args{'rawcompresscmd'} = '/usr/bin/lzop';
|
||||||
$args{'compressargs'} = '';
|
$args{'compressargs'} = '';
|
||||||
$args{'rawdecompresscmd'} = '/usr/bin/lzop';
|
$args{'rawdecompresscmd'} = '/usr/bin/lzop';
|
||||||
|
|
@ -374,8 +377,11 @@ sub checkcommands {
|
||||||
return %avail;
|
return %avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sourcehost ne '') { $sourcessh = "$sshcmd $sourcehost"; }
|
if (!defined $sourcehost) { $sourcehost = ''; }
|
||||||
if ($targethost ne '') { $targetssh = "$sshcmd $targethost"; }
|
if (!defined $targethost) { $targethost = ''; }
|
||||||
|
|
||||||
|
if ($sourcehost ne '') { $sourcessh = "$sshcmd $sourcehost"; } else { $sourcessh = ''; }
|
||||||
|
if ($targethost ne '') { $targetssh = "$sshcmd $targethost"; } else { $targetssh = ''; }
|
||||||
|
|
||||||
# if raw compress command is null, we must have specified no compression. otherwise,
|
# if raw compress command is null, we must have specified no compression. otherwise,
|
||||||
# make sure that compression is available everywhere we need it
|
# make sure that compression is available everywhere we need it
|
||||||
|
|
@ -415,6 +421,12 @@ sub checkcommands {
|
||||||
$t = "ssh:$t";
|
$t = "ssh:$t";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!defined $avail{'sourcecompress'}) { $avail{'sourcecompress'} = ''; }
|
||||||
|
if (!defined $avail{'targetcompress'}) { $avail{'targetcompress'} = ''; }
|
||||||
|
if (!defined $avail{'sourcembuffer'}) { $avail{'sourcembuffer'} = ''; }
|
||||||
|
if (!defined $avail{'targetmbuffer'}) { $avail{'targetmbuffer'} = ''; }
|
||||||
|
|
||||||
|
|
||||||
if ($avail{'sourcecompress'} eq '') {
|
if ($avail{'sourcecompress'} eq '') {
|
||||||
if ($args{'rawcompresscmd'} ne '') {
|
if ($args{'rawcompresscmd'} ne '') {
|
||||||
print "WARN: $args{'compresscmd'} not available on source $s- sync will continue without compression.\n";
|
print "WARN: $args{'compresscmd'} not available on source $s- sync will continue without compression.\n";
|
||||||
|
|
@ -566,12 +578,13 @@ sub buildsynccmd {
|
||||||
# $synccmd = "$sendcmd | $mbuffercmd | $pvcmd | $recvcmd";
|
# $synccmd = "$sendcmd | $mbuffercmd | $pvcmd | $recvcmd";
|
||||||
$synccmd = "$sendcmd |";
|
$synccmd = "$sendcmd |";
|
||||||
# avoid confusion - accept either source-bwlimit or target-bwlimit as the bandwidth limiting option here
|
# avoid confusion - accept either source-bwlimit or target-bwlimit as the bandwidth limiting option here
|
||||||
my $bwlimit;
|
my $bwlimit = '';
|
||||||
if ($args{'source-bwlimit'} eq '') {
|
if (defined $args{'source-bwlimit'}) {
|
||||||
$bwlimit = $args{'target-bwlimit'};
|
|
||||||
} else {
|
|
||||||
$bwlimit = $args{'source-bwlimit'};
|
$bwlimit = $args{'source-bwlimit'};
|
||||||
|
} elsif (defined $args{'target-bwlimit'}) {
|
||||||
|
$bwlimit = $args{'target-bwlimit'};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($avail{'sourcembuffer'}) { $synccmd .= " $mbuffercmd $bwlimit $mbufferoptions |"; }
|
if ($avail{'sourcembuffer'}) { $synccmd .= " $mbuffercmd $bwlimit $mbufferoptions |"; }
|
||||||
if ($avail{'localpv'}) { $synccmd .= " $pvcmd -s $pvsize |"; }
|
if ($avail{'localpv'}) { $synccmd .= " $pvcmd -s $pvsize |"; }
|
||||||
$synccmd .= " $recvcmd";
|
$synccmd .= " $recvcmd";
|
||||||
|
|
@ -806,9 +819,7 @@ sub getsendsize {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $sourcessh;
|
my $sourcessh;
|
||||||
if ($sourcehost ne '') {
|
if ($sourcehost ne '') { $sourcessh = "$sshcmd $sourcehost"; } else { $sourcessh = ''; }
|
||||||
$sourcessh = "$sshcmd $sourcehost";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $getsendsizecmd = "$sourcessh $mysudocmd $zfscmd send -nP $snaps";
|
my $getsendsizecmd = "$sourcessh $mysudocmd $zfscmd send -nP $snaps";
|
||||||
if ($debug) { print "DEBUG: getting estimated transfer size from source $sourcehost using \"$getsendsizecmd 2>&1 |\"...\n"; }
|
if ($debug) { print "DEBUG: getting estimated transfer size from source $sourcehost using \"$getsendsizecmd 2>&1 |\"...\n"; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue