Revision 67b21d42
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/BackgroundJob/CreatePeriodicInvoices.pm | ||
---|---|---|
184 | 184 |
sub _send_email { |
185 | 185 |
my ($posted_invoices, $printed_invoices) = @_; |
186 | 186 |
|
187 |
read_config 'config/lx_office.conf' => my %config;
|
|
187 |
my %config = %::lx_office_conf;
|
|
188 | 188 |
|
189 | 189 |
return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices }; |
190 | 190 |
|
SL/Dispatcher.pm | ||
---|---|---|
15 | 15 |
use English qw(-no_match_vars); |
16 | 16 |
use SL::Auth; |
17 | 17 |
use SL::LXDebug; |
18 |
use SL::LxOfficeConf; |
|
18 | 19 |
use SL::Locale; |
19 | 20 |
use SL::Common; |
20 | 21 |
use SL::Helper::DateTime; |
... | ... | |
66 | 67 |
} |
67 | 68 |
|
68 | 69 |
sub pre_startup_setup { |
69 |
read_config 'config/lx_office.conf' => %::lx_office_conf; |
|
70 |
_decode_recursively(\%::lx_office_conf); |
|
70 |
SL::LxOfficeConf->read; |
|
71 | 71 |
_init_environment(); |
72 | 72 |
|
73 | 73 |
eval { |
... | ... | |
312 | 312 |
return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR); |
313 | 313 |
} |
314 | 314 |
|
315 |
sub _decode_recursively { |
|
316 |
my ($obj) = @_; |
|
317 |
|
|
318 |
while (my ($key, $value) = each %{ $obj }) { |
|
319 |
if (ref($value) eq 'HASH') { |
|
320 |
_decode_recursively($value); |
|
321 |
} else { |
|
322 |
$obj->{$key} = decode('UTF-8', $value); |
|
323 |
} |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 | 315 |
sub _init_environment { |
328 | 316 |
my %key_map = ( lib => { name => 'PERL5LIB', append_path => 1 }, |
329 | 317 |
path => { name => 'PATH', append_path => 1 }, |
SL/LxOfficeConf.pm | ||
---|---|---|
1 |
package SL::LxOfficeConf; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Config::Std; |
|
6 |
use Encode; |
|
7 |
|
|
8 |
sub read { |
|
9 |
my $file = -f 'config/lx_office.conf' ? 'config/lx_office.conf' : 'config/lx_office.conf.default'; |
|
10 |
read_config $file => %::lx_office_conf; |
|
11 |
_decode_recursively(\%::lx_office_conf); |
|
12 |
} |
|
13 |
|
|
14 |
sub _decode_recursively { |
|
15 |
my ($obj) = @_; |
|
16 |
|
|
17 |
while (my ($key, $value) = each %{ $obj }) { |
|
18 |
if (ref($value) eq 'HASH') { |
|
19 |
_decode_recursively($value); |
|
20 |
} else { |
|
21 |
$obj->{$key} = decode('UTF-8', $value); |
|
22 |
} |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
1; |
config/lx_office.conf.default | ||
---|---|---|
99 | 99 |
# The template file used for the email's body. |
100 | 100 |
email_template = templates/webpages/oe/periodic_invoices_email.txt |
101 | 101 |
|
102 |
[Console]
|
|
102 |
[console]
|
|
103 | 103 |
# autologin to use if none is given |
104 | 104 |
login = mb |
105 | 105 |
|
scripts/console | ||
---|---|---|
9 | 9 |
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version. |
10 | 10 |
} |
11 | 11 |
|
12 |
use Config::Std; |
|
13 | 12 |
use Data::Dumper; |
14 | 13 |
use Devel::REPL 1.002001; |
15 | 14 |
use Term::ReadLine::Perl::Bind; # use sane key binding for rxvt users |
16 | 15 |
|
17 |
read_config 'config/lx_office.conf' => my %config; |
|
16 |
use SL::LxOfficeConf; |
|
17 |
SL::LxOfficeConf->read; |
|
18 | 18 |
|
19 |
my $login = shift || $config{Console}{login} || 'demo';
|
|
20 |
my $history_file = $config{Console}{history_file} || '/tmp/lxoffice_console_history.log'; # fallback if users is not writable
|
|
21 |
my $autorun = $config{Console}{autorun};
|
|
19 |
my $login = shift || $::lx_office_conf{console}{login} || 'demo';
|
|
20 |
my $history_file = $::lx_office_conf{console}{history_file} || '/tmp/lxoffice_console_history.log'; # fallback if users is not writable
|
|
21 |
my $autorun = $::lx_office_conf{console}{autorun};
|
|
22 | 22 |
|
23 | 23 |
# will be configed eventually |
24 | 24 |
my @plugins = qw(History LexEnv Colors MultiLine::PPI FancyPrompt PermanentHistory AutoloadModules); |
... | ... | |
41 | 41 |
use CGI qw( -no_xhtml); |
42 | 42 |
use DateTime; |
43 | 43 |
use SL::Auth; |
44 |
use SL::Dispatcher; |
|
45 | 44 |
use SL::Form; |
46 | 45 |
use SL::Helper::DateTime; |
47 | 46 |
use SL::Locale; |
... | ... | |
59 | 58 |
|
60 | 59 |
package main; |
61 | 60 |
|
62 |
read_config 'config/lx_office.conf' => %::lx_office_conf; |
|
63 |
SL::Dispatcher::_decode_recursively(\%::lx_office_conf); |
|
64 |
|
|
65 | 61 |
$::lxdebug = LXDebug->new; |
66 | 62 |
$::locale = Locale->new($::lx_office_conf{system}->{language}); |
67 | 63 |
$::cgi = CGI->new qw(); |
scripts/dbupgrade2_tool.pl | ||
---|---|---|
23 | 23 |
use Text::Iconv; |
24 | 24 |
|
25 | 25 |
use SL::LXDebug; |
26 |
use SL::LxOfficeConf; |
|
26 | 27 |
|
27 |
read_config "config/lx_office.conf" => our %lx_office_conf;
|
|
28 |
SL::LxOfficeConf->read;
|
|
28 | 29 |
our $lxdebug = LXDebug->new(); |
29 | 30 |
|
30 | 31 |
use SL::Auth; |
scripts/rose_auto_create_model.pl | ||
---|---|---|
19 | 19 |
use SL::Form; |
20 | 20 |
use SL::Locale; |
21 | 21 |
use SL::LXDebug; |
22 |
use SL::LxOfficeConf; |
|
22 | 23 |
use SL::DB::Helper::ALL; |
23 | 24 |
use SL::DB::Helper::Mappings; |
24 | 25 |
|
... | ... | |
42 | 43 |
exit 1; |
43 | 44 |
} |
44 | 45 |
|
45 |
read_config "config/lx_office.conf" => %lx_office_conf;
|
|
46 |
SL::LxOfficeConf->read;
|
|
46 | 47 |
|
47 | 48 |
my $login = shift @ARGV; |
48 | 49 |
|
scripts/task_server.pl | ||
---|---|---|
16 | 16 |
} |
17 | 17 |
|
18 | 18 |
use CGI qw( -no_xhtml); |
19 |
use Config::Std; |
|
20 | 19 |
use Cwd; |
21 | 20 |
use Daemon::Generic; |
22 | 21 |
use Data::Dumper; |
... | ... | |
29 | 28 |
use SL::Form; |
30 | 29 |
use SL::Helper::DateTime; |
31 | 30 |
use SL::LXDebug; |
31 |
use SL::LxOfficeConf; |
|
32 | 32 |
use SL::Locale; |
33 | 33 |
|
34 | 34 |
our %lx_office_conf; |
... | ... | |
89 | 89 |
sub gd_preconfig { |
90 | 90 |
my $self = shift; |
91 | 91 |
|
92 |
read_config $self->{configfile} => %lx_office_conf;
|
|
92 |
SL::LxOfficeConf->read;
|
|
93 | 93 |
|
94 | 94 |
die "Missing section [task_server] in config file" unless $lx_office_conf{task_server}; |
95 | 95 |
die "Missing key 'login' in section [task_server] in config file" unless $lx_office_conf{task_server}->{login}; |
... | ... | |
136 | 136 |
|
137 | 137 |
mkdir($pidbase) if !-d $pidbase; |
138 | 138 |
|
139 |
newdaemon(configfile => "${cwd}/config/lx_office.conf", |
|
139 |
my $file = -f "${cwd}/config/lx_office.conf" ? "${cwd}/config/lx_office.conf" : "${cwd}/config/lx_office.conf.default"; |
|
140 |
newdaemon(configfile => $file, |
|
140 | 141 |
progname => 'lx-office-task-server', |
141 | 142 |
pidbase => "${pidbase}/", |
142 | 143 |
); |
Auch abrufbar als: Unified diff
config/lx_office.conf.default einlesen, wenn config/lx_office.conf nicht existiert