stephan: server/perl-kolab/Kolab-Conf Conf.pm,1.38,1.39
cvs at intevation.de
cvs at intevation.de
Tue Sep 21 18:13:04 CEST 2004
Author: stephan
Update of /kolabrepository/server/perl-kolab/Kolab-Conf
In directory doto:/tmp/cvs-serv22339
Modified Files:
Conf.pm
Log Message:
This adds meta data handling for templates to the Kolab Daemon.
Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/Kolab-Conf/Conf.pm,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- Conf.pm 16 Sep 2004 14:31:40 -0000 1.38
+++ Conf.pm 21 Sep 2004 16:13:02 -0000 1.39
@@ -115,6 +115,15 @@
my $skip = 0;
while (<$template>) {
+ #Eat the meta data sections
+ if (/^KOLAB_META_START$/) {
+ my $found_end;
+ while (!$found_end) {
+ $_ = <$template>;
+ $found_end = /^KOLAB_META_END$/;
+ }
+ $_ = <$template>;
+ }
if (/\@{3}if (\S+?)\@{3}/) {
if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
# Keep text
@@ -508,6 +517,62 @@
Kolab::log('T', 'Finished building LDAP replicas', KOLAB_DEBUG);
}
+sub loadMetaTemplates
+{
+ my $templatedir = shift;
+ my ($tref, $pref, $oref) = @_;
+
+ Kolab::log('T', 'Collecting template files', KOLAB_DEBUG );
+ opendir(DIR, $templatedir);
+ my @metatemplates = grep { /\.template$/ } readdir (DIR);
+ closedir(DIR);
+
+ foreach my $template (@metatemplates) {
+ #Open each file and check for the META
+ if (open (TEMPLATE, $template)) {
+ my $line = <TEMPLATE>;
+ if ($line =~ /^KOLAB_META_START$/) {
+ Kolab::log('T', 'Processing META template :'.$template, KOLAB_DEBUG );
+ my ($found_end, $target, $permissions, $ownership);
+ while (<TEMPLATE>) {
+ $line = $_;
+ if (!$found_end) {
+ $found_end = $line =~ /^KOLAB_META_END$/;
+ if (!$found_end && $line) {
+ my ($key,$value) = split(/=/,$line);
+ chomp($value);
+ Kolab::log('T', 'META Key: '.$key.' Value: '.$value, KOLAB_DEBUG );
+ if ($key =~ /^TARGET$/) {
+ $target = $value;
+ Kolab::log('T', 'META Target '.$target, KOLAB_DEBUG );
+ }
+ if ($key =~ /^PERMISSIONS$/) {
+ $permissions = $value;
+ Kolab::log('T', 'META Permissions '.$permissions, KOLAB_DEBUG );
+ }
+ if ($key =~ /^OWNERSHIP$/) {
+ $ownership = $value;
+ Kolab::log('T', 'META Ownership '.$ownership, KOLAB_DEBUG );
+ }
+ }
+ }
+ }
+ if ($found_end && $target && $permissions && $ownership) {
+ Kolab::log('T', 'All mandatory fields populated in '.$template, KOLAB_DEBUG );
+ $$tref{$template} = $target;
+ $$oref{$target} = $ownership;
+ $permissions = oct($permissions);
+ $$pref{$target} = $permissions;
+ }
+
+ }
+ } else {
+ Kolab::log('T', 'Could not open template file: '. $template, KOLAB_WARN);
+ }
+ }
+
+}
+
sub rebuildTemplates
{
my $key;
@@ -583,6 +648,8 @@
Kolab::log('T', 'Regenerating configuration files', KOLAB_DEBUG );
+
+ loadMetaTemplates( $templatedir, \%templates, \%permissions, \%ownership );
foreach $key (keys %templates) {
my $tpl = $templates{$key};
More information about the commits
mailing list