source: LMDZ6/branches/Amaury_dev/tools/fcm/lib/FCM/Admin/Config.pm

Last change on this file was 5129, checked in by abarral, 5 months ago

Re-add removed by mistake fcm

File size: 8.3 KB
Line 
1# ------------------------------------------------------------------------------
2# Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
3#
4# This file is part of FCM, tools for managing and building source code.
5#
6# FCM is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# FCM is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with FCM. If not, see <http://www.gnu.org/licenses/>.
18# ------------------------------------------------------------------------------
19
20use strict;
21use warnings;
22
23package FCM::Admin::Config;
24use base qw{FCM::Class::HASH};
25
26use FCM::Context::Locator;
27use FCM::Util;
28use File::Basename qw{dirname};
29use File::Spec::Functions qw{catfile};
30use FindBin;
31
32our $UTIL = FCM::Util->new();
33
34my $TRAC_LIVE_URL_TMPL = 'https://{host}/trac/{project}';
35my $USER_ID = (getpwuid($<))[0];
36
37__PACKAGE__->class({
38    # Emails
39    admin_email         => {isa => '$', default => $USER_ID},
40    notification_from   => {isa => '$'},
41
42    # Location for log files
43    log_dir             => {isa => '$', default => '/var/log/fcm'},
44
45    # FCM installation locations
46    fcm_home            => {isa => '$', default => dirname($FindBin::Bin)},
47    fcm_site_home       => {isa => '$', default => q{}},
48
49    # FCM installation mirror locations
50    mirror_dests        => {isa => '$', default => q{}},
51    mirror_keys         => {isa => '$', default => q{}},
52
53    # Subversion repositories settings
54    svn_backup_dir      => {isa => '$', default => '/var/svn/backups'},
55    svn_dump_dir        => {isa => '$', default => '/var/svn/dumps'},
56    svn_group           => {isa => '$', default => q{}},
57    svn_hook_path_env   => {isa => '$', default => q{}},
58    svn_live_dir        => {isa => '$', default => '/srv/svn'},
59    svn_passwd_file     => {isa => '$', default => q{}},
60    svn_project_suffix  => {isa => '$', default => q{}},
61
62    # Trac environments settings
63    trac_admin_users    => {isa => '$', default => q{}},
64    trac_backup_dir     => {isa => '$', default => '/var/trac/backups'},
65    trac_group          => {isa => '$', default => q{}},
66    trac_host_name      => {isa => '$', default => 'localhost'},
67    trac_ini_file       => {isa => '$', default => 'trac.ini'},
68    trac_live_dir       => {isa => '$', default => '/srv/trac'},
69    trac_live_url_tmpl  => {isa => '$', default => $TRAC_LIVE_URL_TMPL},
70    trac_passwd_file    => {isa => '$', default => q{}},
71
72    # User information tool settings
73    user_info_tool      => {isa => '$', default => 'passwd'},
74
75    # User information tool, LDAP settings
76    ldappw              => {isa => '$', default => '~/.ldappw'},
77    ldap_uri            => {isa => '$', default => q{}},
78    ldap_binddn         => {isa => '$', default => q{}},
79    ldap_basedn         => {isa => '$', default => q{}},
80    ldap_attrs          => {isa => '$', default => q{uid cn mail}},
81    ldap_filter_more    => {isa => '$', default => q{}},
82
83    # User information tool, passwd settings
84    passwd_email_domain => {isa => '$', default => q{}},
85    passwd_gid_max      => {isa => '$'},
86    passwd_uid_max      => {isa => '$'},
87    passwd_gid_min      => {isa => '$', default => 1000},
88    passwd_uid_min      => {isa => '$', default => 1000},
89});
90
91
92# Returns a unique instance of this class.
93my $INSTANCE;
94sub instance {
95    my ($class) = @_;
96    if (!defined($INSTANCE)) {
97        $INSTANCE = $class->new();
98        # Load $FCM_HOME/etc/fcm/admin.cfg and $HOME/.metomi/fcm/admin.cfg
99        $UTIL->cfg_init(
100            'admin.cfg',
101            sub {
102                my $config_reader = shift();
103                while (defined(my $entry = $config_reader->())) {
104                    my $label = $entry->get_label();
105                    if (exists($INSTANCE->{$label})) {
106                        $INSTANCE->{$label} = $entry->get_value();
107                    }
108                }
109            },
110        );
111    }
112    return $INSTANCE;
113}
114
1151;
116__END__
117
118=head1 NAME
119
120FCM::Admin::Config
121
122=head1 SYNOPSIS
123
124    $config = FCM::Admin::Config->instance();
125    $dir = $config->get_svn_backup_dir();
126    # ...
127
128=head1 DESCRIPTION
129
130This class is used to retrieve/store configurations required by FCM
131admininstration scripts.
132
133It is a sub-class of L<FCM::Class::HASH|FCM::Class::HASH>.
134
135=head1 METHODS
136
137=over 4
138
139=item FCM::Admin::Config->instance()
140
141Returns a unique instance of this class. On first call, creates the instance
142with the configurations set to their default values; and loads from the
143site/user configuration at $FCM_HOME/etc/fcm/admin.cfg and
144$HOME/.metomi/fcm/admin.cfg.
145
146=back
147
148=head1 ATTRIBUTES
149
150Email addresses.
151
152=over 4
153
154=item admin_email
155
156The e-mail address of the FCM administrator.
157
158=item notification_from
159
160Notification email address (for the "From:" field in notification emails).
161
162=back
163
164Location for log files.
165
166=over 4
167
168=item log_dir
169
170The location for log files.
171
172=back
173
174Locations of FCM installation.
175
176=over 4
177
178=item fcm_home
179
180The source path of the default FCM distribution.
181
182=item fcm_site_home
183
184The source path of the default FCM site distribution.
185
186=back
187
188Settings on how to mirror FCM installation.
189
190=over 4
191
192=item mirror_dests
193
194A space-delimited list of destinations to mirror FCM installation.
195
196=item mirror_keys
197
198A string containing a list of source keys. Each source key should point
199to a source location in this $config. The source locations will be distributed
200to the list of destinations in C<mirror_dests>.
201
202=back
203
204Subversion repositories settings.
205
206=over 4
207
208=item svn_backup_dir
209
210The path to a directory containing the backups of SVN repositories.
211
212=item svn_dump_dir
213
214The path to a directory containing the revision dumps of SVN
215repositories.
216
217=item svn_group
218
219The group name in which Subversion repositories should be created in.
220
221=item svn_hook_dir
222
223The path to a directory containing source files of SVN hook scripts.
224
225=item svn_hook_path_env
226
227The value of the PATH environment variable, in which SVN hook scripts
228should run with.
229
230=item svn_live_dir
231
232The path to a directory containing the live SVN repositories.
233
234=item svn_passwd_file
235
236The base name of the SVN password file.
237
238=item svn_project_suffix
239
240The suffix added to the name of each SVN repository.
241
242=back
243
244Trac environment settings.
245
246=over 4
247
248=item trac_admin_users
249
250A space-delimited list of admin users for all Trac environments.
251
252=item trac_backup_dir
253
254The path to a directory containing the backups of Trac environments.
255
256=item trac_group
257
258The group name in which Trac environment files should be created in.
259
260=item trac_host_name
261
262The host name of the Trac server, from the user's perspective.
263
264=item trac_ini_file
265
266The base name of the Trac INI file.
267
268=item trac_live_dir
269
270The path to a directory containing the live Trac environments.
271
272=item trac_live_url_tmpl
273
274The template string for determining the URL of the Trac environment of a
275project.
276
277=item trac_passwd_file
278
279The base name of the Trac password file.
280
281=back
282
283=over 4
284
285User information tool settings.
286
287=item user_info_tool
288
289The name of the tool for obtaining user information.
290
291=back
292
293LDAP settings, only relevant if C<user_info_tool = ldap>
294
295=over 4
296
297=item ldappw
298
299File containing the password to the LDAP server, if required.
300
301=item ldap_uri
302
303The URI of the LDAP server.
304
305=item ldap_binddn
306
307The DN in the LDAP server to bind with to search the directory.
308
309=item ldap_basedn
310
311The DN in the LDAP server that is the base for a search.
312
313=item ldap_attrs
314
315The attributes for UID, common name and email in the LDAP directory.
316
317=item ldap_filter_more
318
319If specified, use the value as extra (AND) filters to an LDAP search.
320
321=back
322
323PASSWD settings, only relevant if user_info_tool = passwd
324
325=over 4
326
327=item passwd_email_domain
328
329Domain name to suffix user IDs to create an email address.
330
331=item passwd_gid_max
332
333Maximum GID considered to be a normal user group.
334
335=item passwd_uid_max
336
337Maximum UID considered to be a normal user.
338
339=item passwd_gid_min
340
341Minimum GID considered to be a normal user group. (default=1000)
342
343=item passwd_uid_min
344
345Minimum UID considered to be a normal user. (default=1000)
346
347=back
348
349=head1 COPYRIGHT
350
351Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
352
353=cut
Note: See TracBrowser for help on using the repository browser.