[1201] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use Getopt::Long; |
---|
| 6 | use Pod::Usage; |
---|
| 7 | use Config::IniFiles; |
---|
| 8 | use LATMOS::Accounts; |
---|
| 9 | use LATMOS::Accounts::SyncManager; |
---|
| 10 | use LATMOS::Accounts::Log; |
---|
| 11 | use 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 | |
---|
| 23 | GetOptions( |
---|
| 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 | |
---|
| 36 | Use this configuration instead default one |
---|
| 37 | |
---|
| 38 | =item --help |
---|
| 39 | |
---|
| 40 | Display this help |
---|
| 41 | |
---|
| 42 | =item --reset|-r module |
---|
| 43 | |
---|
| 44 | Reset the check point to force the module to be rerun even no change occurs in |
---|
| 45 | database. |
---|
| 46 | |
---|
| 47 | If the given module name is C<all>, all module get reset. |
---|
| 48 | |
---|
| 49 | =item --sync|-s |
---|
| 50 | |
---|
| 51 | Tell to L<la-sync-manager> daemon to immediatly perform a synchronisation. |
---|
| 52 | |
---|
| 53 | =back |
---|
| 54 | |
---|
| 55 | =cut |
---|
| 56 | |
---|
| 57 | my $exit = 0; |
---|
| 58 | |
---|
| 59 | if ($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 | |
---|
| 69 | if ($sync) { |
---|
| 70 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
| 71 | $LA->call_batch_sync or $exit=1; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | exit($exit); |
---|
| 75 | |
---|
| 76 | __END__ |
---|
| 77 | |
---|
| 78 | =head1 SEE ALSO |
---|
| 79 | |
---|
| 80 | L<la-sync-manager.ini>, L<latmos-accounts.ini> |
---|
| 81 | |
---|
| 82 | =head1 AUTHOR |
---|
| 83 | |
---|
| 84 | Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> |
---|
| 85 | |
---|
| 86 | =head1 COPYRIGHT AND LICENSE |
---|
| 87 | |
---|
| 88 | Copyright (C) 2008, 2009, 2010, 2011, 2012 CNRS SA/CETP/LATMOS |
---|
| 89 | |
---|
| 90 | This library is free software; you can redistribute it and/or modify |
---|
| 91 | it under the same terms as Perl itself, either Perl version 5.10.0 or, |
---|
| 92 | at your option, any later version of Perl 5 you may have available. |
---|
| 93 | |
---|
| 94 | =cut |
---|