From: Moritz Bunkus Date: Mon, 17 Jan 2011 15:22:13 +0000 (+0100) Subject: Zusammenfassen mehrerer Konfigurationsdateien in einer gemeinsamen X-Git-Tag: release-2.6.3~61^2~7^2~1^2~2^2~7 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f04a7950a3040894b77e09289a71d3931ce898d0;p=kivitendo-erp.git Zusammenfassen mehrerer Konfigurationsdateien in einer gemeinsamen --- diff --git a/.gitignore b/.gitignore index 2ecef792d..999a9bf53 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ crm /users/datev-export* /users/templates-cache/ /users/pid/ -/config/task_server.conf -/config/periodic_invoices.conf +/config/lx_office.conf diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index dc7fd79e3..1a2cf81f5 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -184,7 +184,7 @@ sub _calculate_dates { sub _send_email { my ($posted_invoices, $printed_invoices) = @_; - read_config 'config/periodic_invoices.conf' => my %config; + read_config 'config/lx_office.conf' => my %config; return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices }; diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 3a1e8d84a..687c37306 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -9,7 +9,9 @@ BEGIN { } use CGI qw( -no_xhtml); +use Config::Std; use DateTime; +use Encode; use English qw(-no_match_vars); use SL::Auth; use SL::LXDebug; @@ -92,6 +94,9 @@ sub pre_startup_setup { $::form = undef; %::myconfig = (); %::called_subs = (); # currently used for recursion detection + + read_config 'config/lx_office.conf' => %::lx_office_conf if -f "config/lx_office.conf"; + _decode_recursively(\%::lx_office_conf); } $SIG{__WARN__} = sub { @@ -320,6 +325,18 @@ sub get_standard_filehandles { return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR); } +sub _decode_recursively { + my ($obj) = @_; + + while (my ($key, $value) = each %{ $obj }) { + if (ref($value) eq 'HASH') { + _decode_recursively($value); + } else { + $obj->{$key} = decode('UTF-8', $value); + } + } +} + package main; use strict; diff --git a/config/console.conf.default b/config/console.conf.default deleted file mode 100644 index da291db5d..000000000 --- a/config/console.conf.default +++ /dev/null @@ -1,13 +0,0 @@ -[Console] - -# autologin to use if none is given -login = demo - -# autorun lines will be executed after autologin. -# be warned that loading huge libraries will noticably lengthen startup time. -#autorun = use SL::Module -# = use SL::Other::Module - -# location of history file for permanent history -history_file = users/console_history - diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default new file mode 100644 index 000000000..10cf54c67 --- /dev/null +++ b/config/lx_office.conf.default @@ -0,0 +1,30 @@ +[task_server] +# User name to use for database access +login = mb +# Set to 1 for debug messages in /tmp/lx-office-debug.log +debug = 1 +# Chose a system user the daemon should run under when started as root. +run_as = + +[periodic_invoices] +# The user name a report about the posted and printed invoices is sent +# to. +send_email_to = login +# The "From:" header for said email. +email_from = Lx-Office Daemon +# The subject for said email. +email_subject = Benachrichtigung: automatisch erstellte Rechnungen +# The template file used for the email's body. +email_template = templates/webpages/oe/periodic_invoices_email.txt + +[Console] +# autologin to use if none is given +login = demo + +# autorun lines will be executed after autologin. +# be warned that loading huge libraries will noticably lengthen startup time. +#autorun = use SL::Module +# = use SL::Other::Module + +# location of history file for permanent history +history_file = users/console_history diff --git a/config/periodic_invoices.conf.default b/config/periodic_invoices.conf.default deleted file mode 100644 index 0a92a8390..000000000 --- a/config/periodic_invoices.conf.default +++ /dev/null @@ -1,10 +0,0 @@ -[periodic_invoices] -# The user name a report about the posted and printed invoices is sent -# to. -send_email_to = login -# The "From:" header for said email. -email_from = Lx-Office Daemon -# The subject for said email. -email_subject = Benachrichtigung: automatisch erstellte Rechnungen -# The template file used for the email's body. -email_template = templates/webpages/oe/periodic_invoices_email.txt diff --git a/config/task_server.conf.default b/config/task_server.conf.default deleted file mode 100644 index d72e63d29..000000000 --- a/config/task_server.conf.default +++ /dev/null @@ -1,7 +0,0 @@ -[task_server] -# User name to use for database access -login = -# Set to 1 for debug messages in /tmp/lx-office-debug.log -debug = 0 -# Chose a system user the daemon should run under when started as root. -run_as = www diff --git a/scripts/console b/scripts/console index 42c193ac1..added9f83 100755 --- a/scripts/console +++ b/scripts/console @@ -14,7 +14,7 @@ use Data::Dumper; use Devel::REPL 1.002001; use Term::ReadLine::Perl::Bind; # use sane key binding for rxvt users -read_config 'config/console.conf' => my %config;# if -f 'config/console.conf'; +read_config 'config/lx_office.conf' => my %config; my $login = shift || $config{Console}{login} || 'demo'; my $history_file = $config{Console}{history_file} || '/tmp/lxoffice_console_history.log'; # fallback if users is not writable @@ -41,6 +41,7 @@ use utf8; use CGI qw( -no_xhtml); use DateTime; use SL::Auth; +use SL::Dispatcher; use SL::Form; use SL::Helper::DateTime; use SL::Locale; @@ -73,6 +74,9 @@ sub lxinit { $::form = Form->new; $::auth = SL::Auth->new; + read_config 'config/lx_office.conf' => %::lx_office_conf; + SL::Dispatcher::_decode_recursively(\%::lx_office_conf); + die 'cannot reach auth db' unless $::auth->session_tables_present; $::auth->restore_session; @@ -193,8 +197,8 @@ of the classes they were created with. Configuration of this script is located in: - config/console.conf - config/console.conf.default + config/lx_office.conf + config/lx_office.conf.default See there for interesting options. diff --git a/scripts/task_server.pl b/scripts/task_server.pl index bbe3353ae..ee087dba4 100755 --- a/scripts/task_server.pl +++ b/scripts/task_server.pl @@ -145,7 +145,7 @@ my $pidbase = "${cwd}/users/pid"; mkdir($pidbase) if !-d $pidbase; -newdaemon(configfile => "${cwd}/config/task_server.conf", +newdaemon(configfile => "${cwd}/config/lx_office.conf", progname => 'lx-office-task-server', pidbase => "${pidbase}/", );