Revision 72033e2d
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
scripts/console | ||
---|---|---|
19 | 19 |
use SL::LxOfficeConf; |
20 | 20 |
SL::LxOfficeConf->read; |
21 | 21 |
|
22 |
my $client = $::lx_office_conf{console}{client}; |
|
22 | 23 |
my $login = $::lx_office_conf{console}{login} || 'demo'; |
23 | 24 |
my $history_file = $::lx_office_conf{console}{history_file} || '/tmp/kivitendo_console_history.log'; # fallback if users is not writable |
24 | 25 |
my $debug_file = $::lx_office_conf{console}{log_file} || '/tmp/kivitendo_console_debug.log'; |
... | ... | |
27 | 28 |
|
28 | 29 |
my $result = GetOptions( |
29 | 30 |
"login|l=s" => \$login, |
31 |
"client|c=s" => \$client, |
|
30 | 32 |
"history-file|i=s" => \$history_file, |
31 | 33 |
"log-file|o=s" => \$debug_file, |
32 | 34 |
"execute|e=s" => \$execute_code, |
... | ... | |
61 | 63 |
$repl->load_plugin($_) for @plugins; |
62 | 64 |
$repl->load_history($history_file); |
63 | 65 |
$repl->eval('help'); |
64 |
$repl->print("trying to auto login as '$login'...");
|
|
65 |
$repl->print($repl->eval("lxinit '$login'"));
|
|
66 |
$repl->print("trying to auto login into client '$client' with login '$login'...\n");
|
|
67 |
execute_code($repl, "lxinit '$client', '$login'");
|
|
66 | 68 |
|
67 | 69 |
my @code_to_execute = grep { $_ } ($autorun, $execute_code, $execute_file ? join('', read_file($execute_file)) : undef); |
68 | 70 |
execute_code($repl, $_) || exit 1 for @code_to_execute; |
... | ... | |
89 | 91 |
# it is assumed that anyone with physical access and execution rights on this script |
90 | 92 |
# won't be hindered by authentication anyway. |
91 | 93 |
sub lxinit { |
92 |
my $login = shift;
|
|
94 |
my ($client, $login) = @_;
|
|
93 | 95 |
|
94 |
die 'need login' unless $login;
|
|
96 |
die 'need client and login' unless $client && $login;
|
|
95 | 97 |
|
96 | 98 |
package main; |
97 | 99 |
|
... | ... | |
99 | 101 |
$::locale = Locale->new($::lx_office_conf{system}->{language}); |
100 | 102 |
$::form = Form->new; |
101 | 103 |
$::auth = SL::Auth->new; |
104 |
die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client); |
|
105 |
|
|
102 | 106 |
$::instance_conf = SL::InstanceConfiguration->new; |
103 | 107 |
$::request = SL::Request->new( |
104 | 108 |
cgi => CGI->new({}), |
Auch abrufbar als: Unified diff
console: um Spezifikation vom Client erweitert