App-DistSync

 view release on metacpan or  search on metacpan

bin/distsync  view on Meta::CPAN

By default, every SSL/TLS connection client makes is verified to be secure.
This option allows client to proceed and operate even for server connections
otherwise considered insecure.

The server connection is verified by making sure the server's certificate
contains the right name and verifies successfully using the cert store.

=item B<-T secs, --timeout=secs>

Set timeout for HTTP requests

=item B<-V, --version>

Print the version number of the program and quit

=item B<-v, --verbose>

Verbose mode. Show extended information on STDOUT

=item B<-x PROXY_URL, --proxy=PROXY_URL>

Sets proxy URL (http/socks4/socks5)

For example: socks://user:pass@192.168.0.1:1080

=back

=head1 DESCRIPTION

Launcher of synchronization via App::DistSync

See C<README> file for details

=head1 AUTHOR

Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright (C) 1998-2025 D&D Corporation. All Rights Reserved

=head1 LICENSE

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See L<https://dev.perl.org/licenses/>

=cut

use Getopt::Long;
use Pod::Usage;

use Cwd qw/getcwd/;
use File::Spec;

use App::DistSync;
use App::DistSync::LockFile;
use App::DistSync::Util;

binmode STDOUT, ':utf8';
binmode STDERR, ':utf8';


use constant {
    PIDFILE     => 'distsync.pid',
    CMDDEFAULT  => 'sync',
    COMMANDS    => [qw/init status sync manifest mkmani/],
};

$| = 1;  # Autoflush on

my $options = {};
Getopt::Long::Configure ("bundling");
GetOptions($options,
    # Information and debug
    "help|usage|h",         # Show help page
    "longhelp|H|?",         # Show long help page
    "debug|devel|d",        # Debug mode
    "verbose|v",            # Verbose mode
    "version|ver|V",        # Print VERSION of the project

    # Client options
    "proxy|x=s",            # Proxy URL
    "insecure|k",           # Insecure connection
    "timeout|T=i",          # Timeoute value in seconds. Default - 60

    # Project
    "directory|dir|D=s",    # Directory
    "delay|i=i",            # Delay. 0 - off, 1-n - secs, default - 3600
) || pod2usage(-exitval => 1, -verbose => 0, -output => \*STDERR);
pod2usage(-exitval => 0, -verbose => 1) if $options->{help};
pod2usage(-exitval => 0, -verbose => 2) if $options->{longhelp};
printf("DistSync v%s\n", App::DistSync->VERSION) && exit(0) if $options->{version};

# Get command
my $command   = @ARGV ? shift @ARGV : CMDDEFAULT;
pod2usage(-exitval => 1, -verbose => 99, -sections => 'SYNOPSIS|OPTIONS|COMMANDS', -output => \*STDERR)
    unless scalar grep {$_ eq $command} @{(COMMANDS)};

# Work directory
my $dir = $options->{directory} || shift(@ARGV) || getcwd();
die sprintf("Directory \"%s\" not exists", $dir) unless $dir && (-e $dir) && (-d $dir or -l $dir);

# Debugging on
$App::DistSync::Util::DEBUG = $App::DistSync::DEBUG = 1 if $options->{debug};

# Start process
my $started = time;
debug("%s START", tms);

# Lock file
my $lock = App::DistSync::LockFile->new(
        file => File::Spec->catfile($dir, App::DistSync::MANILOCK()),
        $options->{delay} ? (delay => $options->{delay}) : (),
        pid => $$,
    );
if ($lock->lock->error) {
    warn $lock->error . "\n";
    goto FINISH;
}



( run in 1.594 second using v1.01-cache-2.11-cpan-140bd7fdf52 )