mathieu: server/perl-kolab/lib/Kolab Conf.pm,1.14,1.15
cvs at kolab.org
cvs at kolab.org
Sun Dec 13 18:54:25 CET 2009
Author: mathieu
Update of /kolabrepository/server/perl-kolab/lib/Kolab
In directory doto:/tmp/cvs-serv26677/perl-kolab/lib/Kolab
Modified Files:
Conf.pm
Log Message:
Touch configuration only when there is a change. This avoid postfix
complaining about "database X.db is older than source file X".
Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/lib/Kolab/Conf.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Conf.pm 13 Dec 2009 16:05:38 -0000 1.14
+++ Conf.pm 13 Dec 2009 17:54:23 -0000 1.15
@@ -56,7 +56,7 @@
my %templates = ();
my %ownership = ();
my %permissions = ();
-my %templatehaschanged = ();
+my %confighaschanged = ();
my %commentchar = ();
sub fixup {
@@ -120,20 +120,8 @@
my $perm = shift;
my $cchr = shift; # comment character
- my $oldcfg = $cfg . '.old';
my $templatedir = $Kolab::config{"templatedir"};
- my $oldmask = umask 077;
- #creating the config file is changing it
- if (! -f $cfg) {
- $templatehaschanged{$tmpl} = 1;
- Kolab::log('T', "`$cfg' creation detected", KOLAB_DEBUG );
- }
- copy($cfg, $oldcfg);
- # To avoid warnings, the backup files must be owned by root
- chown(0, 0, $oldcfg);
- umask $oldmask;
-
Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'", KOLAB_DEBUG );
my $template;
@@ -276,17 +264,30 @@
$template->close;
$config->close;
- move($config->filename, $cfg) || Kolab::log('T', "Error moving configfile to $cfg, error: $!", KOLAB_ERROR );
- fixup( $cfg, $owner, $perm );
- if (-f $oldcfg) {
- my $rc = `diff -q $cfg $oldcfg`;
+ if (-f $cfg) {
+ my $cfgtemp = $config->filename;
+ my $rc = `diff -q $cfg $cfgtemp`;
chomp($rc);
if ($rc) {
- $templatehaschanged{$tmpl} = 1;
-
Kolab::log('T', "`$cfg' change detected: $rc", KOLAB_DEBUG );
+ $confighaschanged{$tmpl} = 1;
+ #making backup
+ my $cfgbackup = $cfg . '.old';
+ my $oldmask = umask 077;
+ move($cfg, $cfgbackup) || Kolab::log('T', "Error backuping configfile to $cfgbackup, error: $!", KOLAB_ERROR );
+ # To avoid warnings, the backup files must be owned by root
+ chown(0, 0, $cfgbackup);
+ umask $oldmask;
}
+ } else {
+ Kolab::log('T', "`$cfg' creation detected", KOLAB_DEBUG );
+ $confighaschanged{$tmpl} = 1;
+ }
+
+ if($confighaschanged{$tmpl}) {
+ move($config->filename, $cfg) || Kolab::log('T', "Error moving configfile to $cfg, error: $!", KOLAB_ERROR );
+ fixup( $cfg, $owner, $perm );
}
Kolab::log('T', "Finished creating configuration file `$cfg'", KOLAB_DEBUG );
@@ -621,7 +622,7 @@
my %cmds = ();
foreach $key (keys %runonchange) {
- if (defined $templatehaschanged{$key})
+ if (defined $confighaschanged{$key})
{
Kolab::log('T', 'Queueing RUNONCHANGE for '.$key, KOLAB_DEBUG );
$cmds{$runonchange{$key}} = 1;
More information about the commits
mailing list