X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FInstaller.pm;h=43fd724bf2a6ae886e6645544cce34253ac54647;hb=b96c8b7ffa265251db3c0402adbfd68ec499cad9;hp=2436d3b28581f4cf376bcc1989d0a0396fadd5a5;hpb=aa9b4d92cdfc9147f4da4033f4cbc0245f0ac9d1;p=koha_gimpoz diff --git a/C4/Installer.pm b/C4/Installer.pm old mode 100644 new mode 100755 index 2436d3b285..43fd724bf2 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -354,6 +354,9 @@ sub load_sql_in_order { $request->execute; my ($systempreference) = $request->fetchrow; $systempreference = '' unless defined $systempreference; # avoid warning + # Make sure the global sysprefs.sql file is loaded first + my $globalsysprefs = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/sysprefs.sql"; + unshift(@fnames, $globalsysprefs); foreach my $file (@fnames) { # warn $file; undef $/; @@ -505,8 +508,13 @@ sub load_sql { my $datadir = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}"; my $error; my $strcmd; + my $cmd; if ( $self->{dbms} eq 'mysql' ) { - $strcmd = "mysql " + $cmd = qx(which mysql 2>/dev/null || whereis mysql 2>/dev/null); + chomp $cmd; + $cmd = $1 if ($cmd && $cmd =~ /^(.+?)[\r\n]+$/); + $cmd = 'mysql' if (!$cmd || !-x $cmd); + $strcmd = "$cmd " . ( $self->{hostname} ? " -h $self->{hostname} " : "" ) . ( $self->{port} ? " -P $self->{port} " : "" ) . ( $self->{user} ? " -u $self->{user} " : "" ) @@ -514,7 +522,11 @@ sub load_sql { . " $self->{dbname} "; $error = qx($strcmd --default-character-set=utf8 <$filename 2>&1 1>/dev/null); } elsif ( $self->{dbms} eq 'Pg' ) { - $strcmd = "psql " + $cmd = qx(which psql 2>/dev/null || whereis psql 2>/dev/null); + chomp $cmd; + $cmd = $1 if ($cmd && $cmd =~ /^(.+?)[\r\n]+$/); + $cmd = 'psql' if (!$cmd || !-x $cmd); + $strcmd = "$cmd " . ( $self->{hostname} ? " -h $self->{hostname} " : "" ) . ( $self->{port} ? " -p $self->{port} " : "" ) . ( $self->{user} ? " -U $self->{user} " : "" ) @@ -526,8 +538,10 @@ sub load_sql { # report the import a failure although it really succeded -fbcit } # errors thrown while loading installer data should be logged - warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n"; - warn $error; + if($error) { + warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n"; + warn "$error"; + } return $error; } @@ -575,7 +589,7 @@ sub get_file_path_from_name { C4::Installer is a refactoring of logic originally from installer/installer.pl, which was originally written by Henri-Damien Laurant. -Koha Development Team +Koha Development Team Galen Charlton