source: LATMOS-Accounts/bin/la-expired-reminder @ 861

Last change on this file since 861 was 861, checked in by nanardon, 13 years ago
  • reimport missing files from previous svn
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts::Maintenance;
6use LATMOS::Accounts::Log;
7use Getopt::Long;
8use Pod::Usage;
9
10=head1 NAME
11
12    la-expired-reminder - Notify manager about expired account needing deletion
13
14=head1 SYNOPSIS
15
16    la-expired-reminder [options]
17
18=cut
19
20GetOptions(
21    'c|config=s' => \my $config,
22#    'b|base=s'   => \my $base,
23    'm|mail'     => \my $mail,
24    'help'       => sub { pod2usage(0) },
25    'users|u=s'  => \my @users,
26    'to=s'       => \my $to,
27    'at=s'       => \my $delay,
28    'test'       => \my $test,
29) or pod2usage();
30
31=head1 OPTIONS
32
33=over 4
34
35=item -c|--config configdir
36
37Use this configuration directory instead of the default one.
38
39=item -m|mail
40
41Send a mail to user(s) concerned by the future expiration of his/her/their account(s).
42
43=item u|user USER
44
45Send email only to this user if his/her account will expire. Usefull for
46testing and not sending hundred of mails.
47
48Multiple users can be specified by using -u several times
49
50=item --to MAIL
51
52Instead sending email to user(s) and eventually his/her/their manager(s), send the mail to
53only this email address.
54
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
63=item --test
64
65With -m, do not send mail but tell to who the mail would have been sent
66
67=back
68
69=head1 CONFIGURATION
70
71Some variables are taken from configuration directory:
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
87=back
88
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
94=cut
95
96if (!$test) {
97    la_set_log(
98        syslog => [],
99        console => undef,
100    );
101}
102
103my $LA = LATMOS::Accounts::Maintenance->new($config);
104
105if ($mail) {
106    $LA->expired_account_reminder(
107        to => $to,
108        users => (@users ? \@users : undef),
109        delay => $delay,
110        test => $test,
111    );
112} else {
113    foreach ($LA->find_expired_users($delay)) {
114        printf("%s\n", $_,);
115    }
116}
Note: See TracBrowser for help on using the repository browser.