source: trunk/LATMOS-Accounts/bin/la-sync-ctl @ 1659

Last change on this file since 1659 was 1201, checked in by nanardon, 11 years ago

add tools to reset (bug #3)

File size: 1.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Getopt::Long;
6use Pod::Usage;
7use Config::IniFiles;
8use LATMOS::Accounts;
9use LATMOS::Accounts::SyncManager;
10use LATMOS::Accounts::Log;
11use LATMOS::Accounts::Task;
12
13=head1 NAME
14
15    la-sync-manager - Daemon performing synchronisation and various tasks
16
17=head1 SYNOPSIS
18
19    la-sync-manager [options...]
20
21=cut
22
23GetOptions(
24    'c|config=s'   => \my $config,
25    'help'         => sub { pod2usage(0) },
26    'r|reset=s'    => \my $reset,
27    's|sync'       => \my $sync,
28) or pod2usage();
29
30=head1 OPTIONS
31
32=over 4
33
34=item -c|--config configdir
35
36Use this configuration instead default one
37
38=item --help
39
40Display this help
41
42=item --reset|-r module
43
44Reset the check point to force the module to be rerun even no change occurs in
45database.
46
47If the given module name is C<all>, all module get reset.
48
49=item --sync|-s
50
51Tell to L<la-sync-manager> daemon to immediatly perform a synchronisation.
52
53=back
54
55=cut
56
57my $exit = 0;
58
59if ($reset) {
60    my $syncm = LATMOS::Accounts::SyncManager->new($config) or do {
61        la_log LA_ERR, "Cannot instanciate Sync Manager";
62        exit(1);
63    };
64    foreach ($reset eq 'all' ? ($syncm->list_modules) : ($reset)) {
65        $syncm->reset_module_checkpoint($_) or $exit=1;
66    }
67}
68
69if ($sync) {
70    my $LA = LATMOS::Accounts->new($config, noacl => 1);
71    $LA->call_batch_sync or $exit=1;
72}
73
74exit($exit);
75
76__END__
77
78=head1 SEE ALSO
79
80L<la-sync-manager.ini>, L<latmos-accounts.ini>
81
82=head1 AUTHOR
83
84Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
85
86=head1 COPYRIGHT AND LICENSE
87
88Copyright (C) 2008, 2009, 2010, 2011, 2012 CNRS SA/CETP/LATMOS
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself, either Perl version 5.10.0 or,
92at your option, any later version of Perl 5 you may have available.
93
94=cut
Note: See TracBrowser for help on using the repository browser.