Last change
on this file since 2043 was
1922,
checked in by nanardon, 7 years ago
|
add some debug message, update dpmt for manager
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1855] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use LATMOS::Accounts; |
---|
| 6 | use Getopt::Long; |
---|
| 7 | use Pod::Usage; |
---|
| 8 | |
---|
| 9 | =head1 NAME |
---|
| 10 | |
---|
| 11 | la-sql-recompute - Update computed attribute |
---|
| 12 | |
---|
| 13 | =head1 SYNOPSIS |
---|
| 14 | |
---|
| 15 | la-sql-upgrade [options] |
---|
| 16 | |
---|
| 17 | =cut |
---|
| 18 | |
---|
| 19 | GetOptions( |
---|
| 20 | 'c|config=s' => \my $config, |
---|
| 21 | 'b|base=s' => \my $base, |
---|
| 22 | 'no-commit' => \my $nocommit, |
---|
| 23 | 'v|verbose' => \my $verbose, |
---|
| 24 | 'h|help' => sub { pod2usage(1); }, |
---|
| 25 | ) or pod2usage(); |
---|
| 26 | |
---|
| 27 | =head1 OPTIONS |
---|
| 28 | |
---|
| 29 | =over 4 |
---|
| 30 | |
---|
| 31 | =item -c|--config configdir |
---|
| 32 | |
---|
| 33 | Use this configuration directory instead of the default one. |
---|
| 34 | |
---|
| 35 | =item -b|--base basename |
---|
| 36 | |
---|
| 37 | Query this specific base instead of the default one. |
---|
| 38 | |
---|
| 39 | =back |
---|
| 40 | |
---|
| 41 | =cut |
---|
| 42 | |
---|
| 43 | $| = 1; # autoflush |
---|
| 44 | |
---|
| 45 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
| 46 | my $labase = $LA->base($base); |
---|
| 47 | $labase->wexported(1); |
---|
| 48 | |
---|
| 49 | foreach my $user ($labase->list_objects('user')) { |
---|
| 50 | print "Updating user $user\n"; |
---|
| 51 | my $ouser = $labase->get_object('user', $user) or next; |
---|
| 52 | $ouser->computeEmploymentDate(); |
---|
| 53 | } |
---|
| 54 | |
---|
[1922] | 55 | foreach my $group ($labase->search_objects('group', 'sutype=dpmt')) { |
---|
| 56 | print "Updating group $group\n"; |
---|
| 57 | my $ogroup = $labase->get_object('group', $group) or next; |
---|
| 58 | $ogroup->_update_employment_manager; |
---|
| 59 | } |
---|
| 60 | |
---|
[1855] | 61 | $labase->PopulateDynData; |
---|
| 62 | |
---|
| 63 | if ($nocommit) { |
---|
| 64 | $labase->rollback; |
---|
| 65 | } else { |
---|
| 66 | $labase->commit; |
---|
| 67 | } |
---|
| 68 | print "Process terminated successfully\n"; |
---|
Note: See
TracBrowser
for help on using the repository browser.