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

Last change on this file since 656 was 594, checked in by vivat, 14 years ago

Typos dans l'aide en ligne de commande

  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 1.9 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    'test'         => \my $test,
29    'o|object=s'   => \my $otype,
30    's|syncname=s' => \my $syncname,
31    'b|batch'    => \my $batch,
32) or pod2usage();
33
34=head1 OPTIONS
35
36=item -c|--config configfile
37
38Use this configuration file instead of the default one.
39
40=item --from basename
41
42Specify source base to use
43
44=item --to basename
45
46Specify destination base to use, this option can be used
47severals times
48
49=item --nocreate
50
51Don't create anything (???).
52
53=item --test
54
55Don't change anything, just test (???).
56
57=item -s|--syncname name
58
59Use "name" as syncname (???) -> je pense que ce n'est pas une option mais obligatoire, non ?.
60
61=item -o|object object_type
62
63Query will be performed on this object. Default is the 'User' object.
64
65=item -b|--batch
66
67Don't really perform any synchronisation but try to call daemon process
68to perform immediate synchronisation.
69
70=cut
71
72my $LA = LATMOS::Accounts->new($config, noacl => 1);
73
74if ($batch) {
75    exit ($LA->call_batch_sync ? 0 : 1);
76}
77
78my $sync = $LA->create_synchro(
79    $syncname,
80    from => $from,
81    to => (@to ? [ @to ] : undef),
82    nocreate => $nocreate,
83    test     => $test,
84) or die "cannot create sync object\n";
85$sync->load_dest and return;
86if ($otype) {
87    foreach (@ARGV) {
88        warn "Try to sync $otype: $_\n";
89        $sync->sync_object($otype, $_) or do {
90            warn "Error while synching $_ ($otype)\n";
91            exit 1;
92        }
93    }
94} else {
95    $sync->process() or warn "Sync has failed\n";
96}
97
98exit 0;
Note: See TracBrowser for help on using the repository browser.