2013-11-17 13:58:21 -05:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
#use Getopt::Long;
|
|
|
|
|
2013-11-17 21:48:53 -05:00
|
|
|
my $strCommandCompress = "pigz --rsyncable --best --stdout %file%";
|
|
|
|
my $strCommandHash = "sha1sum %file% | awk '{print \$1}'";
|
|
|
|
|
2013-11-17 13:58:21 -05:00
|
|
|
sub execute
|
|
|
|
{
|
|
|
|
local($strCommand) = @_;
|
|
|
|
my $strOutput;
|
|
|
|
|
2013-11-17 21:48:53 -05:00
|
|
|
# print("$strCommand\n");
|
2013-11-17 13:58:21 -05:00
|
|
|
$strOutput = qx($strCommand) or return 0;
|
2013-11-17 21:48:53 -05:00
|
|
|
# print("$strOutput\n");
|
|
|
|
|
|
|
|
return($strOutput);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub file_hash_get
|
|
|
|
{
|
|
|
|
local($strFile) = @_;
|
|
|
|
|
|
|
|
my $strCommand = $strCommandHash;
|
|
|
|
$strCommand =~ s/\%file\%/$strFile/g;
|
|
|
|
|
|
|
|
my $strHash = execute($strCommand);
|
|
|
|
$strHash =~ s/^\s+|\s+$//g;
|
|
|
|
|
|
|
|
return($strHash);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the command
|
|
|
|
$strCommand = $ARGV[0];
|
|
|
|
|
|
|
|
if ($strCommand eq "archive-local")
|
|
|
|
{
|
|
|
|
my $strSource = $ARGV[1];
|
|
|
|
my $strDestination = $ARGV[2];
|
|
|
|
|
|
|
|
my $strCommand = $strCommandCompress;
|
|
|
|
$strCommand =~ s/\%file\%/$strFile/g;
|
|
|
|
|
|
|
|
my $strHash = file_hash_get($strSource);
|
|
|
|
|
|
|
|
$strCommand !!! construct the rest of the string
|
2013-11-17 13:58:21 -05:00
|
|
|
|
2013-11-17 21:48:53 -05:00
|
|
|
print("$strHash");
|
|
|
|
# execute("$strCommandCompress $strSource >
|
2013-11-17 13:58:21 -05:00
|
|
|
}
|
|
|
|
|
2013-11-22 17:29:01 -05:00
|
|
|
|
|
|
|
|