source: LATMOS-Accounts/bin/la-sync @ 578

Last change on this file since 578 was 578, checked in by nanardon, 15 years ago
  • add a daemon to manage synchronisation as batch
  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 1.6 KB
RevLine 
[41]1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use LATMOS::Accounts::Synchro;
7use Getopt::Long;
8use Pod::Usage;
9
10=head1 NAME
11
12    la-sync - Tools to synchronize base
13
14=head1 SYNOPSIS
15
16Show configured bases:
17
[73]18    la-sync [sync name] [options]
[41]19
20=cut
21
22GetOptions(
[132]23    'c|config=s'   => \my $config,
24    'help'         => sub { pod2usage(0) },
25    'from=s'       => \my $from,
26    'to=s'         => \my @to,
27    'nocreate'     => \my $nocreate,
28    'test'         => \my $test,
29    'o|object=s'   => \my $otype,
30    's|syncname=s' => \my $syncname,
[578]31    'b|batch'    => \my $batch,
[41]32) or pod2usage();
33
34=head1 OPTIONS
35
36=item -c|--config configfile
37
38Use this configuration file instead default
39
40=item --from basename
41
42Specify souce base to use
43
44=item --to basename
45
46Specify destination base to use, this option can be used
47severals times
48
[578]49=item -b|--batch
50
51Don't really perform any synchronisation but try to call daemon process
52to perform immediate synchronisation.
53
[41]54=cut
55
[457]56my $LA = LATMOS::Accounts->new($config, noacl => 1);
[41]57
[578]58if ($batch) {
59    exit ($LA->call_batch_sync ? 0 : 1);
60}
61
[73]62my $sync = $LA->create_synchro(
[132]63    $syncname,
[73]64    from => $from,
65    to => (@to ? [ @to ] : undef),
[66]66    nocreate => $nocreate,
67    test     => $test,
[73]68) or die "cannot create sync object\n";
69$sync->load_dest and return;
[83]70if ($otype) {
71    foreach (@ARGV) {
72        warn "Try to sync $otype: $_\n";
[197]73        $sync->sync_object($otype, $_) or do {
74            warn "Error while synching $_ ($otype)\n";
75            exit 1;
76        }
[83]77    }
78} else {
79    $sync->process() or warn "Sync has failed\n";
80}
[197]81
82exit 0;
Note: See TracBrowser for help on using the repository browser.