[Rt-commit] r12839 - rt/branches/3.8-TESTING/lib/RT

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Jun 3 13:09:27 EDT 2008


Author: sunnavy
Date: Tue Jun  3 13:09:26 2008
New Revision: 12839

Modified:
   rt/branches/3.8-TESTING/lib/RT/Installer.pm

Log:
refactor a bit, don't clobber existing irrelevant settings in RT_SiteConfig.pm either

Modified: rt/branches/3.8-TESTING/lib/RT/Installer.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Installer.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Installer.pm	Tue Jun  3 13:09:26 2008
@@ -256,32 +256,28 @@
 
     my $file = $class->ConfigFile;
 
-    if ( open my $fh, '>', $file  ) {
-        print $fh <<EOF;
-# Any configuration directives you include  here will override 
-# RT's default configuration file, RT_Config.pm
-#
-# To include a directive here, just copy the equivalent statement
-# from RT_Config.pm and change the value. We've included a single
-# sample value below.
-#
-# This file is actually a perl module, so you can include valid
-# perl code, as well.
-#
-# The converse is also true, if this file isn't valid perl, you're
-# going to run into trouble. To check your SiteConfig file, use
-# this comamnd:
-#
-#   perl -c /path/to/your/etc/RT_SiteConfig.pm
+    my $content;
+
+    {
+        local $/;
+        open my $fh, '<', $file or die $!;
+        $content = <$fh>;
+        $content =~ s/^\s*1;\s*$//m;
+    }
 
-EOF
+    if ( open my $fh, '>', $file  ) {
         for ( keys %{$RT::Installer->{InstallConfig}} ) {
             if (defined $RT::Installer->{InstallConfig}{$_}) {
-                print $fh "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
+                # remove obsolete settings we'll add later
+                $content =~ s/^\s* Set \s* \( \s* \$$_ .*$//xm;
+
+                $content .= "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
             }
         }
-        print $fh "1;\n";
+        $content .= "1;\n";
+        print $fh $content;
         close $fh;
+
         return ( 1, "Successfully saved configuration to $file." );
     }
 


More information about the Rt-commit mailing list