diff options
-rw-r--r-- | Build.PL | 1 | ||||
-rw-r--r-- | LedgerSMB/Sysconfig.pm | 35 | ||||
-rw-r--r-- | ledger-smb.conf.default | 80 |
3 files changed, 68 insertions, 48 deletions
@@ -24,6 +24,7 @@ my $build = Module::Build->new ( 'Locale::Language' => 0, 'Time::Local' => 0, 'Cwd' => 0, + 'Config::Std' => 0, }, recommends => { 'HTML::LinkExtor' => 0, diff --git a/LedgerSMB/Sysconfig.pm b/LedgerSMB/Sysconfig.pm index 3c5cb348..a8b2e827 100644 --- a/LedgerSMB/Sysconfig.pm +++ b/LedgerSMB/Sysconfig.pm @@ -4,6 +4,8 @@ package LedgerSMB::Sysconfig; +use Config::Std; + $session='DB'; $logging=0; # No logging on by default @@ -53,10 +55,35 @@ my $globalDBConnect = 'dbi:Pg:dbname=ledgersmb;host=localhost;port=5432'; my $globalUserName = "ledgersmb"; my $globalPassword = "set me to correct password"; -eval { require "ledger-smb.conf"; }; -if ($@){ - print STDERR "Parsing ledger-smb.conf failed: $@"; -} +my %config; +read_config('ledger-smb.conf' => %config) or die; + +$logging = $config{''}{logging} if $config{''}{logging}; +$check_max_invoices = $config{''}{check_max_invoices} if + $config{''}{check_max_invoices}; +$language = $config{''}{language} if $config{''}{language}; +$session = $config{''}{session} if $config{''}{session}; +$latex = $config{''}{latex} if $config{''}{latex}; + +$ENV{PATH} .= ":".(join ':', @{$config{environment}{PATH}}) if + $config{environment}{PATH}; +$ENV{PERL5LIB} .= ":".(join ':', @{$config{environment}{PERL5LIB}}) if + $config{environment}{PERL5LIB}; + +%printer = %{$config{printers}} if $config{printers}; + +$memberfile = $config{paths}{memberfile} if $config{paths}{memberfile}; +$userspath = $config{paths}{userspath} if $config{paths}{userspath}; +$localepath = $config{paths}{localepath} if $config{paths}{localepath}; +$spool = $config{paths}{spool} if $config{paths}{spool}; +$templates = $config{paths}{tempates} if $config{paths}{tempates}; + +$sendmail = $config{programs}{sendmail} if $config{programs}{sendmail}; +$gzip = $config{programs}{gzip} if $config{programs}{gzip}; + +$globalDBConnect = $config{globaldb}{DBConnect} if $config{globaldb}{DBConnect}; +$globalUserName = $config{globaldb}{UserName} if $config{globaldb}{UserName}; +$globalPassword = $config{globaldb}{Password} if $config{globaldb}{Password}; #$GLOBALDBH = DBI->connect($globalDBConnect, $globalDBUserName, $globalDBPassword); diff --git a/ledger-smb.conf.default b/ledger-smb.conf.default index 07a657db..8e71cfa5 100644 --- a/ledger-smb.conf.default +++ b/ledger-smb.conf.default @@ -1,55 +1,47 @@ -use vars qw($userspath $spool $memberfile $templates $sendmail $language $sid $latex %printer $gzip $GLOBALDBH); +session : DB +logging : 0 -################################# -# Global database parameters -################################# -# These parameters *must* be set correctly -# for LedgerSMB >= 1.2 to work -my $globalDBConnect = 'dbi:Pg:dbname=ledgersmb;host=localhost;port=5432'; -my $globalUserName = "ledgersmb"; -my $globalPassword = "set me to correct password"; +# Set language for login and admin pages +language : -$GLOBALDBH = DBI->connect($globalDBConnect, $globalDBUserName, $globalDBPassword); +# If you have LaTeX installed, set to 1 +latex : 1 -# path to user configuration files -$userspath = "users"; +# Maximum number of invoices that can be printed on a cheque +check_max_invoices : 5 -# spool directory for batch printing -$spool = "spool"; +[environment] +# If the server can't find applications, append to the path +PATH: /usr/local/pgsql/bin +PATH: /usr/local/bin -# templates base directory -$templates = "templates"; +# If on Mac OS X using Fink's Perl libs, append to the path +#PERL5LIB = /sw/lib/perl5 +[paths] +# spool directory for batch printing +spool = spool +# path to user configuration files +userspath = users +# templates base directory +templates = templates # member file -$memberfile = "users/members"; - -# location of sendmail -$sendmail = "| /usr/sbin/sendmail -t"; - -# set language for login and admin -$language = ""; - -# Maximum number of invoices that can be printed on a check -$check_max_invoices = 5; - - -# if you have latex installed set to 1 -$latex = 1; - -# available printers -%printer = ( Laser => 'lpr -Plaser', - Epson => 'lpr -PEpson', - ); +memberfile = users/members +localepath = locale/po +[programs] +sendmail = | /usr/bin/sendmail -t # program to use for file compression -$gzip = "gzip -S .gz"; +gzip = gzip -S .gz -# if the server can't find gzip, latex, dvips or pdflatex, add the path -$ENV{PATH} .= ":/usr/local/bin:/usr/local/pgsql/bin"; - -# on mac os X using Fink's Perl libs, add the path -#$ENV{PERL5LIB} .= ":/sw/lib/perl5"; - - -1; +[printers] +# Available printers +Laser = lpr -Plaser +Epson = lpr -PEpson +[globaldb] +# These paramaters *must* be set correctly +# for LedgerSMB >= 1.2 to work +DBConnect = dbi:Pg:dbname=ledgersmb;host=localhost;port5432 +UserName = ledgersmb +Password = set me to correct password |