X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FInstaller.pm;h=43fd724bf2a6ae886e6645544cce34253ac54647;hb=26bee7eee7d3e4602bc5e757278f600224fcbdf5;hp=1c177b96814ba81948acb2eb7d8626966cbdcf0b;hpb=147ae6c665cd25a07471d90afcab3e38ce36d9e0;p=koha_gimpoz diff --git a/C4/Installer.pm b/C4/Installer.pm old mode 100644 new mode 100755 index 1c177b9681..43fd724bf2 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -508,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} " : "" ) @@ -517,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} " : "" ) @@ -529,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; }