1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts::Maintenance; |
---|
6 | use LATMOS::Accounts::Log; |
---|
7 | use Getopt::Long; |
---|
8 | use 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 | |
---|
20 | GetOptions( |
---|
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 | 'test' => \my $test, |
---|
28 | ) or pod2usage(); |
---|
29 | |
---|
30 | =head1 OPTIONS |
---|
31 | |
---|
32 | =over 4 |
---|
33 | |
---|
34 | =item -c|--config configdir |
---|
35 | |
---|
36 | Use this configuration directory instead of the default one. |
---|
37 | |
---|
38 | =item -m|mail |
---|
39 | |
---|
40 | Send a mail to user(s) concerned by the future expiration of his/her/their account(s). |
---|
41 | |
---|
42 | =item u|user USER |
---|
43 | |
---|
44 | Send email only to this user if his/her account will expire. Usefull for |
---|
45 | testing and not sending hundred of mails. |
---|
46 | |
---|
47 | Multiple users can be specified by using -u several times |
---|
48 | |
---|
49 | =item --to MAIL |
---|
50 | |
---|
51 | Instead sending email to user(s) and eventually his/her/their manager(s), send the mail to |
---|
52 | only this email address. |
---|
53 | |
---|
54 | =item --test |
---|
55 | |
---|
56 | With -m, do not send mail but tell to who the mail would have been sent |
---|
57 | |
---|
58 | =back |
---|
59 | |
---|
60 | =head1 CONFIGURATION |
---|
61 | |
---|
62 | Some variables are taken from configuration directory: |
---|
63 | |
---|
64 | =over 4 |
---|
65 | |
---|
66 | =item mailFrom |
---|
67 | |
---|
68 | Specify the From address to use in mail |
---|
69 | |
---|
70 | =item smtp |
---|
71 | |
---|
72 | The smtp server to use to send mail |
---|
73 | |
---|
74 | =item alwayscc |
---|
75 | |
---|
76 | In normal mode (without --to), the mail is also sent this email address. |
---|
77 | |
---|
78 | =back |
---|
79 | |
---|
80 | =head1 USERS EMAIL ADDRESSES |
---|
81 | |
---|
82 | The mail use to send warning to users and manager is taken from 'mail' |
---|
83 | attributes. If the attributes is unset, the user will not receive the mail. |
---|
84 | |
---|
85 | =cut |
---|
86 | |
---|
87 | if (!$test) { |
---|
88 | la_set_log( |
---|
89 | syslog => [], |
---|
90 | console => undef, |
---|
91 | ); |
---|
92 | } |
---|
93 | |
---|
94 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
95 | my $labase = $LA->base($base); |
---|
96 | $labase && $labase->load or die "Cannot load base"; |
---|
97 | $labase->wexported(1); |
---|
98 | |
---|
99 | |
---|
100 | foreach (qw(check_user_manager check_group_manager check_nethost_owner)) { |
---|
101 | my %res = $labase->$_; |
---|
102 | if (%res) { |
---|
103 | warn "\n$_:\n"; |
---|
104 | foreach (sort keys %res) { |
---|
105 | warn " $_ $res{$_}\n"; |
---|
106 | } |
---|
107 | } |
---|
108 | } |
---|
109 | # $labase->check_user_manager; |
---|
110 | # $labase->check_group_manager; |
---|
111 | # $labase->check_nethost_owner; |
---|