source: trunk/LATMOS-Accounts/bin/la-warn-expire @ 1907

Last change on this file since 1907 was 1762, checked in by nanardon, 8 years ago

Fix: display expiration

  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 2.2 KB
RevLine 
[410]1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts::Maintenance;
[711]6use LATMOS::Accounts::Log;
[410]7use Getopt::Long;
8use Pod::Usage;
9
10=head1 NAME
11
[424]12    la-warn-expire - query expiration of user and send mail
[410]13
14=head1 SYNOPSIS
15
[594]16    la-warn-expire [options]
[410]17
18=cut
19
20GetOptions(
21    'c|config=s' => \my $config,
[413]22#    'b|base=s'   => \my $base,
[410]23    'm|mail'     => \my $mail,
24    'help'       => sub { pod2usage(0) },
[704]25    'users|u=s'  => \my @users,
[417]26    'to=s'       => \my $to,
[704]27    'at=s'       => \my $delay,
[710]28    'test'       => \my $test,
[410]29) or pod2usage();
30
31=head1 OPTIONS
32
33=over 4
34
[861]35=item -c|--config configdir
[410]36
[861]37Use this configuration directory instead of the default one.
[410]38
[417]39=item -m|mail
[410]40
[594]41Send a mail to user(s) concerned by the future expiration of his/her/their account(s).
[410]42
[417]43=item u|user USER
[410]44
[594]45Send email only to this user if his/her account will expire. Usefull for
46testing and not sending hundred of mails.
[410]47
[417]48Multiple users can be specified by using -u several times
[410]49
[417]50=item --to MAIL
[410]51
[594]52Instead sending email to user(s) and eventually his/her/their manager(s), send the mail to
[417]53only this email address.
[410]54
[704]55=item --at DELAY
56
57Search account expiring in DELAY. Delay must must a number follow by a time
58unit. Example:
59
60    1 month
61    2 days
62
[778]63=item --test
64
65With -m, do not send mail but tell to who the mail would have been sent
66
[417]67=back
[410]68
[417]69=head1 CONFIGURATION
70
[861]71Some variables are taken from configuration directory:
[417]72
73=over 4
74
75=item mailFrom
76
77Specify the From address to use in mail
78
79=item smtp
80
81The smtp server to use to send mail
82
83=item alwayscc
84
85In normal mode (without --to), the mail is also sent this email address.
86
[410]87=back
88
[417]89=head1 USERS EMAIL ADDRESSES
90
91The mail use to send warning to users and manager is taken from 'mail'
92attributes. If the attributes is unset, the user will not receive the mail.
93
[410]94=cut
95
[711]96if (!$test) {
97    la_set_log(
98        syslog => [],
99        console => undef,
100    );
101}
102
[410]103my $LA = LATMOS::Accounts::Maintenance->new($config);
104
105if ($mail) {
[704]106    $LA->warn_next_expire_users(
107        to => $to,
108        users => (@users ? \@users : undef),
[710]109        delay => $delay,
110        test => $test,
[704]111    );
[410]112} else {
[704]113    foreach ($LA->find_next_expire_users($delay)) {
[1762]114        printf("%4s jours: %s (%s)\n", $_->{days}, $_->{obj}->get_c_field('displayName'),
[410]115            $_->{obj}->id);
116    }
117}
Note: See TracBrowser for help on using the repository browser.