richard: server/kolabconf/lib/Kolab Conf.pm,1.20,1.21

cvs at kolab.org cvs at kolab.org
Mon Sep 8 21:28:02 CEST 2008


Author: richard

Update of /kolabrepository/server/kolabconf/lib/Kolab
In directory doto:/tmp/cvs-serv10597/lib/Kolab

Modified Files:
	Conf.pm 
Log Message:
added code to include warnings in a configuration
file, by replacing the macro @@@warning@@@ in the config file.
See kolab/issue1671.



Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/kolabconf/lib/Kolab/Conf.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Conf.pm	6 Sep 2008 14:41:46 -0000	1.20
+++ Conf.pm	8 Sep 2008 19:28:00 -0000	1.21
@@ -83,13 +83,49 @@
     }
 }
 
+sub printWarning {
+
+    my $stream = shift;
+    my $templateFile = shift;
+    my $cc = shift;
+
+    $templateFile = "" if (!defined $templateFile);
+    $cc = "#" if (!defined $cc);
+
+    # Different warnings during bootstrapping and regular configuration
+# $Kolab::config{"bootstrap_config"} = "true";
+    if ((defined $Kolab::config{"bootstrap_config"}) &&
+        ($Kolab::config{"bootstrap_config"} eq "true")) {
+
+        print $stream "$cc=================================================================\n";
+        print $stream "$cc This is a preliminary version of this configuration file and\n";
+        print $stream "$cc only used for bootstrapping.  If you see this warning in your\n";
+        print $stream "$cc configuration after bootstrapping the Kolab Server\n";
+        print $stream "$cc SOMETHING WENT VERY WRONG !!!\n";
+        print $stream "$cc=================================================================\n";
+
+    } else {
+
+        print $stream "$cc=================================================================\n";
+        print $stream "$cc THIS FILE IS AUTOMATICALLY WRITTEN BY THE KOLAB CONFIG BACKEND.\n";
+        print $stream "$cc MANUAL CHANGES ARE LOST UNLESS MADE IN THE TEMPLATE FILE:\n";
+        print $stream "$cc\n";
+        print $stream "$cc  $templateFile\n";
+        print $stream "$cc\n";
+        print $stream "$cc Changes can be activated by running ".$Kolab::config{'kolabconf_script'}."\n";
+        print $stream "$cc=================================================================\n";
+
+    }
+}
+
 sub build {
     my $tmpl = shift;
     my $cfg = shift;
     my $owner = shift;
     my $perm = shift;
+    my $cchr = shift;  # comment character
+
     my $oldcfg = $cfg . '.old';
-    
     my $templatedir = $Kolab::config{"templatedir"};
 
     my %special_templates = (
@@ -176,9 +212,15 @@
                 $skip++;
 	    }
             s/\@{3}else\@{3}\n?//;
+
         } elsif (/\@{3}endif\@{3}/) {
             ($skip > 0) && $skip--;
             s/\@{3}endif\@{3}\n?//;
+
+        } elsif (/\@{3}warning\@{3}/) { 
+
+            printWarning($config, $tmpl, $cchr);
+
         } else {
             while (/\@{3}([^\s\@]+?)(\|(.+?)\((.*)\))?\@{3}/) {
 		my $attr = $1;
@@ -700,7 +742,7 @@
     foreach $key (keys %templates) {
 	my $tpl = $templates{$key};
 	#print STDOUT "Rebuilding $key => $templates{$key}\n";
-	build($key, $tpl, $ownership{$tpl}, $permissions{$tpl} );
+	build($key, $tpl, $ownership{$tpl}, $permissions{$tpl}, $commentchar{$tpl});
     }
 
     buildPostfixTransportMap;
@@ -741,7 +783,7 @@
     foreach my $tpl (@templ) {
       $cfg = $templates{$tpl};
       # print STDOUT "Rebuilding $tpl => $cfg\n";
-      build($tpl, $cfg, $ownership{$cfg}, $permissions{$cfg} );
+      build($tpl, $cfg, $ownership{$cfg}, $permissions{$cfg}, $commentchar{$cfg});
     }
 }
 





More information about the commits mailing list