steffen: server/perl-kolab/Kolab-Conf Conf.pm,1.16,1.17

cvs at intevation.de cvs at intevation.de
Mon Jun 14 04:13:05 CEST 2004


Author: steffen

Update of /kolabrepository/server/perl-kolab/Kolab-Conf
In directory doto:/tmp/cvs-serv29138/perl-kolab/Kolab-Conf

Modified Files:
	Conf.pm 
Log Message:
more group stuff

Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/Kolab-Conf/Conf.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Conf.pm	11 Jun 2004 09:55:24 -0000	1.16
+++ Conf.pm	14 Jun 2004 02:13:02 -0000	1.17
@@ -45,7 +45,7 @@
         &buildPostfixTransportMap
         &buildCyrusConfig
         &buildCyrusGroups
-        &buildCyrusReplicas
+        &buildLDAPReplicas
         &rebuildTemplates
         %haschanged
     ) ]
@@ -90,6 +90,7 @@
     #chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
 
     Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'");
+    #print STDERR "Creating new configuration file `$cfg' from template `$tmpl'\n";
 
     my $template;
     if (!($template = IO::File->new($tmpl, 'r'))) {
@@ -110,20 +111,21 @@
 
     my $skip = 0;
     while (<$template>) {
-      if (/\@{3}if (\S+)\@{3}/) {
+      if (/\@{3}if (\S+?)\@{3}/) {
 	if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
           # Keep text
 	} else {
           # Skip text
           $skip++;
         }
-        s/\@{3}if (\S+)\@{3}//;
+        s/\@{3}if (\S+?)\@{3}//;
       } elsif (/\@{3}endif\@{3}/) {
         ( $skip > 0 ) && $skip--;
         s/\@{3}endif\@{3}//;
-      } elsif (/\@{3}(\S+)(|[^\@]+)?\@{3}/) {
+      } elsif (/\@{3}(\S+?)(\|.+?)?\@{3}/) {
 	my $attr = $1;
 	my $opt  = $2;
+	#print STDERR "attr=$attr, opt=$opt\n";
 	if ($Kolab::config{$attr}) {
 	  my $val = "";
 	  if( ref $Kolab::config{$attr} eq "ARRAY" ) {
@@ -135,10 +137,10 @@
 	  } else {
 	    $val = $Kolab::config{$attr};
 	  }
-	  s/\@{3}(\S+)\@{3}/$val/g;
+	  s/\@{3}(\S+?)(\|.+?)?\@{3}/$val/g;
 	} else {
 	  Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
-	  s/\@{3}(\S+)\@{3}//g;
+	  s/\@{3}(\S+?)\@{3}//g;
 	}
       }
       ( $skip == 0 ) && print $config $_;
@@ -229,6 +231,41 @@
         Kolab::log('T', 'No Postfix transport map entries found');
     }
 
+    # Build transport rules for groups 
+    $mesg = $ldap->search( base => 'cn=groups,'.$Kolab::config{'base_dn'},
+			   scope => 'sub',
+			   filter => '(objectClass=kInetOrgPerson)' );
+    if ($mesg->code) {
+        Kolab::log('T', 'Unable to locate groups transport map entries in LDAP', KOLAB_ERROR);
+        exit(1);
+    }    
+    if ($mesg->code <= 0) {
+        foreach $ldapobject ($mesg->entries) {
+	    my $mail = $ldapobject->get_value('mail');
+	    $mail = trim($mail);
+	    print $transport  "$mail \tkolabgroup:localhost\n";
+        }
+    } else {
+        Kolab::log('T', 'No Postfix transport map entries found');
+    }
+    # Build transport rules for resources
+    $mesg = $ldap->search( base => 'cn=resources,'.$Kolab::config{'base_dn'},
+			   scope => 'sub',
+			   filter => '(objectClass=kInetOrgPerson)' );
+    if ($mesg->code) {
+        Kolab::log('T', 'Unable to locate resources transport map entries in LDAP', KOLAB_ERROR);
+        exit(1);
+    }    
+    if ($mesg->code <= 0) {
+        foreach $ldapobject ($mesg->entries) {
+	    my $mail = $ldapobject->get_value('mail');
+	    $mail = trim($mail);
+	    print $transport  "$mail \tkolabres:localhost\n";
+        }
+    } else {
+        Kolab::log('T', 'No Postfix transport map entries found');
+    }
+
     Kolab::LDAP::destroy($ldap);
     $transport->close;
 
@@ -387,16 +424,16 @@
     Kolab::log('T', 'Finished building Cyrus groups');
 }
 
-sub buildCyrusReplicas
+sub buildLDAPReplicas
 {
-    Kolab::log('T', 'Building Cyrus replicas');
+    Kolab::log('T', 'Building LDAP replicas');
 
     my $prefix = $Kolab::config{'prefix'};
-    my $cfg = "$prefix/etc/imapd/imapd.replicas";
+    my $cfg = "$prefix/etc/openldap/slapd.replicas";
     my $oldcfg = $cfg . '.old';
     copy($cfg, $oldcfg);
     chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
-    copy("$prefix/etc/kolab/templates/imapd.replicas.template", $cfg);
+    copy("$prefix/etc/kolab/templates/slapd.replicas.template", $cfg);
     my $repl;
     if (!($repl = IO::File->new($cfg, 'a'))) {
         Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -420,13 +457,13 @@
         chomp($rc);
         if ($rc) {
            Kolab::log('T', "`$cfg' change detected: $rc", KOLAB_DEBUG);
-           $Kolab::haschanged{'imapd'} = 1;
+           $Kolab::haschanged{'sldapd'} = 1;
         }
     } else {
-        $Kolab::haschanged{'imapd'} = 1;
+        $Kolab::haschanged{'sldapd'} = 1;
     }
 
-    Kolab::log('T', 'Finished building Cyrus replicas');
+    Kolab::log('T', 'Finished building LDAP replicas');
 }
 
 sub rebuildTemplates
@@ -508,9 +545,9 @@
     }
 
     buildPostfixTransportMap;
+    buildLDAPReplicas;
     buildCyrusConfig;
     buildCyrusGroups;
-    buildCyrusReplicas;
 
     Kolab::log('T', 'Finished regenerating configuration files');
 }





More information about the commits mailing list