ASNMTAP
view release on metacpan or search on metacpan
applications/tools/templates/master/rsync-wrapper-distributed-example.sh view on Meta::CPAN
#!/usr/bin/env perl
# ------------------------------------------------------------------------------
# © Copyright 2003-2011 Alex Peeters [alex.peeters@citap.be]
# ------------------------------------------------------------------------------
# rsync-wrapper-distributed.sh for asnmtap, v2.002.xxx - wrapper script for rsync
# execution via ssh key for use with rsync-mirror-distributed.sh & rsync-mirror.conf
#
# rsync-wrapper need to be installed onto the master server into /opt/asnmtap/applications/master and
# rsync-mirror.sh & rsync-mirror.conf onto the slave server into /opt/asnmtap/applications/slave
#
# Accepted rsync calls are as follows:
# rsync --server --sender @options . $chrootDir/../../otherdir would succeed
#
# '../' are forbidden into a directory of filename for security reasons !!!
# ------------------------------------------------------------------------------
# vi hosts.allow
# rsync: <hostname slave distributed servers>
#
# vi hosts.deny
# rsync: ALL
# ------------------------------------------------------------------------------
use strict;
# Chroot Dir
my $chrootDir = '/opt/asnmtap/results/';
# Where to log successes and failures to set to /dev/null to turn off logging.
my $filename = '/opt/asnmtap/asnmtap/log/rsync-wrapper-distributed-template.log';
# What you want sent if access is denied.
my $denyString = 'Access Denied! Sorry';
# The real path of rsync.
my $rsyncPath = '/usr/bin/rsync';
# 1 = rsync version 2.6.7 or higher or 0 = otherwise
my $rsync_version_2_6_7_or_higher = 1;
# 1 = 'capture_exec("$system_action")' or 0 = 'system ("$system_action")'
my $captureOutput = 1;
# ------------------------------------------------------------------------------
# DON'T TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!
# ------------------------------------------------------------------------------
my @options = ('-logDtpr', '-nlogDtpr', '-vlogDtpr', '-vnlogDtpr',
'-logDtprz', '-nlogDtprz', '-vlogDtprz', '-vnlogDtprz',
'-logDtprc', '-nlogDtprc', '-vlogDtprc', '-vnlogDtprc',
'-logDtprcz', '-nlogDtprcz', '-vlogDtprcz', '-vnlogDtprcz',
'-logDtprcze.s', '-nlogDtprcze.s', '-vlogDtprcze.s', '-vnlogDtprcze.s',
'-logDtprcze.is', '-nlogDtprcze.is', '-vlogDtprcze.is', '-vnlogDtprcze.is');
my $TRUE = (0 == 0);
my $FALSE = (0 == 1);
my $debug = $FALSE;
# ------------------------------------------------------------------------------
my ($rvOpen, $dummy, $argPos);
$rvOpen = open (SSHOUT, "+>>$filename");
unless ( $rvOpen ) {
print STDERR "Couldn't open log '$filename'!\n";
exit 0;
}
my $now = localtime;
# Unset the path, so all commands must have the full path. This avoids any path attacks.
delete $ENV{PATH};
( run in 0.534 second using v1.01-cache-2.11-cpan-39bf76dae61 )