[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4965] trunk



Revision: 4965
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4965&view=rev
Author:   einhverfr
Date:     2012-07-11 02:45:57 +0000 (Wed, 11 Jul 2012)
Log Message:
-----------
Fixing ledgersmb.conf parsing

Modified Paths:
--------------
    trunk/LedgerSMB/Sysconfig.pm
    trunk/ledgersmb.conf.default

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2012-07-10 10:14:33 UTC (rev 4964)
+++ trunk/LedgerSMB/Sysconfig.pm	2012-07-11 02:45:57 UTC (rev 4965)
@@ -97,8 +97,7 @@
 # available printers
 our %printer;
 
-our %config;
-tie %config, 'Config::IniFiles', (-file=> 'ledgersmb.conf' );
+my $cfg = Config::IniFiles->new( -file => "ledgersmb.conf" ) || die @Config::IniFiles::errors;
 
 # Root variables
 for my $var (
@@ -107,7 +106,7 @@
     return_accno no_db_str tempdir cache_templates fs_cssdir)
   )
 {
-    ${$var} = $config{main}{$var} if $config{main}{$var};
+    ${$var} = $cfg->val('main', $var) if $cfg->val('main', $var);
 }
 
 
@@ -115,42 +114,40 @@
     $cssdir = "$cssdir/";
 }
 
-%printer = %{ $config{printers} } if $config{printers};
+for ($cfg->Parameters('printers')){
+     $printer{$_} = $cfg->val('printers', $_);   
+}
 
 # ENV Paths
 for my $var (qw(PATH PERL5LIB)) {
-    if (ref $config{environment}{$var} eq 'ARRAY') {
-        $ENV{$var} .= $pathsep . ( join $pathsep, @{ $config{environment}{$var} } );
-    } elsif ($config{environment}{$var}) {
-        $ENV{$var} .= $pathsep . $config{environment}{$var};
-    }
+     $ENV{$var} .= $pathsep . ( join $pathsep, $cfg->val('environment', $var));
 }
 
 # Application-specific paths
 for my $var (qw(localepath spool templates images)) {
-    ${$var} = $config{paths}{$var} if $config{paths}{$var};
+    ${$var} = $cfg->val('paths', $var) if $cfg->val('paths', $var);
 }
 
 # Programs
 for my $var (qw(gzip)) {
-    ${$var} = $config{programs}{$var} if $config{programs}{$var};
+    ${$var} = $cfg->val('prigrams', $var) if $cfg->val('prigrams', $var);
 }
 
 # mail configuration
 for my $var (qw(sendmail smtphost smtptimeout smtpuser 
              smtppass smtpauthmethod backup_email_from)) 
 {
-    ${$var} = $config{mail}{$var} if $config{mail}{$var};
+    ${$var} = $cfg->val('mail', $var) if $cfg->val('mail', $var);
 }
 
 my $modules_loglevel_overrides='';
-my %tmp=%{$config{log4perl_config_modules_loglevel}} if $config{log4perl_config_modules_loglevel};
-for(sort keys %tmp)
-{
- #print STDERR "Sysconfig key=$_ value=$tmp{$_}\n";
- $modules_loglevel_overrides=$modules_loglevel_overrides.'log4perl.logger.'.$_.'='.$tmp{$_}."\n";
+
+for (sort $cfg->Parameters('log4perl_config_modules_loglevel')){
+  print STDERR "Sysconfig key=$_ value=" . 
+        $cfg->val('log4perl_config_modules_loglevel', $_) ."\n";
+  $modules_loglevel_overrides.='log4perl.logger.'.$_.'='.
+        $cfg->val('log4perl_config_modules_loglevel', $_)."\n";
 }
-#print STDERR localtime()." Sysconfig \$modules_loglevel_overrides=$modules_loglevel_overrides\n";
 # Log4perl configuration
 our $log4perl_config = qq(
     log4perl.rootlogger = $log_level, Basic, Debug
@@ -193,12 +190,13 @@
 #log4perl.logger.LedgerSMB.ScriptLib.Company=TRACE
 #print STDERR localtime()." Sysconfig log4perl_config=$log4perl_config\n";
 
-$ENV{PGHOST} = $config{database}{host};
-$ENV{PGPORT} = $config{database}{port};
-our $default_db = $config{database}{default_db};
-our $db_namespace = $config{database}{db_namespace} || 'public';
-$ENV{PGSSLMODE} = $config{database}{sslmode} if $config{database}{sslmode};
-$ENV{PG_CONTRIB_DIR} = $config{database}{contrib_dir};
+$ENV{PGHOST} = $cfg->val('database', 'host');
+$ENV{PGPORT} = $cfg->val('database', 'port');
+our $default_db = $cfg->val('database', 'default_db');
+our $db_namespace = $cfg->val('database', 'db_namespace') || 'public';
+$ENV{PGSSLMODE} = $cfg->val('database', 'sslmode') 
+    if $cfg->val('database', 'sslmode');
+$ENV{PG_CONTRIB_DIR} = $cfg->val('database', 'contrib_dir');
 
 $ENV{HOME} = $tempdir;
 

Modified: trunk/ledgersmb.conf.default
===================================================================
--- trunk/ledgersmb.conf.default	2012-07-10 10:14:33 UTC (rev 4964)
+++ trunk/ledgersmb.conf.default	2012-07-11 02:45:57 UTC (rev 4965)
@@ -42,7 +42,7 @@
 
 [environment]
 # If the server can't find applications, append to the path
-PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/pgsql/bin
+PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/pgsql/bin
 
 # If on Mac OS X using Fink's Perl libs, append to the path
 #PERL5LIB = /sw/lib/perl5

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.