View | Details | Raw Unified | Return to bug 13793
Collapse All | Expand All

(-)a/installer/install.pl (-12 / +26 lines)
Lines 6-12 use diagnostics; Link Here
6
6
7
use C4::InstallAuth;
7
use C4::InstallAuth;
8
use CGI qw ( -utf8 );
8
use CGI qw ( -utf8 );
9
use IPC::Cmd;
9
use POSIX qw(strftime);
10
10
11
use C4::Context;
11
use C4::Context;
12
use C4::Output;
12
use C4::Output;
Lines 320-339 elsif ( $step && $step == 3 ) { Link Here
320
        warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n";
320
        warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n";
321
    }
321
    }
322
322
323
        my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl";
323
        my $now = POSIX::strftime( "%Y-%m-%dT%H:%M:%S", localtime() );
324
        my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = IPC::Cmd::run(command => $cmd, verbose => 0);
324
        my $logdir = C4::Context->config('logdir');
325
        my ( $logfilepath, $logfilepath_errors ) = ( $logdir . "/updatedatabase_$now.log", $logdir . "/updatedatabase-error_$now.log" );
325
326
326
        if (@$stdout_buf) {
327
        my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl > $logfilepath 2> $logfilepath_errors";
327
            $template->param(update_report => [ map { { line => $_ } } split(/\n/, join('', @$stdout_buf)) ] );
328
328
            $template->param(has_update_succeeds => 1);
329
        system($cmd );
330
331
        my $fh;
332
        open( $fh, "<", $logfilepath ) or die "Cannot open log file $logfilepath: $!";
333
        my @report = <$fh>;
334
        close $fh;
335
        if (@report) {
336
            $template->param( update_report => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] );
337
            $template->param( has_update_succeeds => 1 );
338
        } else {
339
            eval{ `rm $logfilepath` };
329
        }
340
        }
330
        if (@$stderr_buf) {
341
        open( $fh, "<", $logfilepath_errors ) or die "Cannot open log file $logfilepath_errors: $!";
331
            $template->param(update_errors => [ map { { line => $_ } } split(/\n/, join('', @$stderr_buf)) ] );
342
        @report = <$fh>;
332
            $template->param(has_update_errors => 1);
343
        close $fh;
344
        if (@report) {
345
            $template->param( update_errors => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] );
346
            $template->param( has_update_errors => 1 );
333
            warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n";
347
            warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n";
334
            foreach my $line (@$stderr_buf) {warn "$line\n";}
348
            foreach my $line (@report) { warn "$line\n"; }
349
        } else {
350
            eval{ `rm $logfilepath_errors` };
335
        }
351
        }
336
337
        $template->param( $op => 1 );
352
        $template->param( $op => 1 );
338
    }
353
    }
339
    else {
354
    else {
340
- 

Return to bug 13793