source: trunk/LATMOS-Accounts/bin/la-sync @ 1427

Last change on this file since 1427 was 1375, checked in by nanardon, 9 years ago

Fix POD

  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 2.2 KB
Line 
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
18    la-sync [options]
19
20=cut
21
22GetOptions(
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    'nodelete'     => \my $nodelete,
29    'test'         => \my $test,
30    'o|object=s'   => \my $otype,
31    's|syncname=s' => \my $syncname,
32    'b|batch'      => \my $batch,
33    'unexp'        => \my $unexp,
34) or pod2usage();
35
36=head1 OPTIONS
37
38=over 4
39
40=item -c|--config configdir
41
42Use this configuration directory instead of the default one.
43
44=item --from basename
45
46Specify source base to use
47
48=item --to basename
49
50Specify destination base to use, this option can be used
51severals times
52
53=item --nocreate
54
55Don't create object, synchronize existing
56
57=item --test
58
59Don't change anything, just test
60
61=item -s|--syncname name
62
63Use synchronisation named C<name> in configuration instead default
64
65=item -o|object object_type
66
67Query will be performed on this object. Default is the 'User' object.
68
69=item -b|--batch
70
71Don't really perform any synchronisation but try to call daemon process
72to perform immediate synchronisation.
73
74=item --unexp
75
76Sync unexported objects in source base
77
78=back
79
80=cut
81
82my $LA = LATMOS::Accounts->new($config, noacl => 1);
83
84if ($batch) {
85    warn "Using la-sync -b is deprecated, use la-sync-ctl -s instead\n";
86    exit ($LA->call_batch_sync ? 0 : 1);
87}
88
89my $sync = $LA->create_synchro(
90    $syncname,
91    from => $from,
92    to => (@to ? [ @to ] : undef),
93    test     => $test,
94    unexported => $unexp,
95) or die "cannot create sync object\n";
96$sync->load_dest and return;
97if ($otype) {
98    foreach (@ARGV) {
99        warn "Try to sync $otype: $_\n";
100        $sync->sync_object($otype, $_, onepass => 1) or do {
101            warn "Error while synching $_ ($otype)\n";
102            exit 1;
103        }
104    }
105} else {
106    $sync->process(
107        test     => $test,
108        nodelete => $nodelete,
109        nocreate => $nocreate,
110    ) or warn "Sync has failed\n";
111}
112
113exit 0;
Note: See TracBrowser for help on using the repository browser.