From 70dccacee53693493235e81cb34dde8fe57ad4a2 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 11 Feb 2008 16:21:50 -0600 Subject: [PATCH] FRBR: configure PazPar2 during installation Also added koha-pazpar2-ctl.sh to start and stop PazPar2. Signed-off-by: Joshua Ferraro --- C4/Search.pm | 2 +- Makefile.PL | 61 +++++++++++++++++++++++++++++++++++- etc/koha-conf.xml | 12 +++++++ etc/pazpar2/koha-biblios.xml | 4 +-- etc/pazpar2/pazpar2.xml | 4 +-- misc/bin/koha-pazpar2-ctl.sh | 31 ++++++++++++++++++ rewrite-config.PL | 5 +++ 7 files changed, 113 insertions(+), 6 deletions(-) create mode 100755 misc/bin/koha-pazpar2-ctl.sh diff --git a/C4/Search.pm b/C4/Search.pm index 2235d62290..e079a0dc1a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -620,7 +620,7 @@ sub pazGetRecords { $query_type, $scan ) = @_; - my $paz = C4::Search::PazPar2->new('http://localhost:10006/search.pz2'); + my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url')); $paz->init(); $paz->search($simple_query); sleep 1; diff --git a/Makefile.PL b/Makefile.PL index bf08ff4271..9a7121967f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -201,6 +201,10 @@ command-line, e.g., READMEs. Directory for Apache and Zebra logs produced by Koha. +=item PAZPAR2_CONF_DIR + +Directory for PazPar2 configuration files. + =item NONE This is a dummy target used to explicitly state @@ -230,6 +234,7 @@ my $target_map = { './edithelp.pl' => 'INTRANET_CGI_DIR', './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 }, './etc/zebradb' => { target => 'ZEBRA_CONF_DIR', trimdir => -1 }, + './etc/pazpar2' => { target => 'PAZPAR2_CONF_DIR', trimdir => -1 }, './help.pl' => 'INTRANET_CGI_DIR', './installer-CPAN.pl' => 'NONE', './installer' => 'INTRANET_CGI_DIR', @@ -370,6 +375,7 @@ my %config_defaults = ( 'DB_PASS' => 'katikoan', 'INSTALL_ZEBRA' => 'yes', 'INSTALL_SRU' => 'yes', + 'INSTALL_PAZPAR2' => 'no', 'AUTH_INDEX_MODE' => 'grs1', 'ZEBRA_MARC_FORMAT' => 'marc21', 'ZEBRA_LANGUAGE' => 'en', @@ -380,6 +386,10 @@ my %config_defaults = ( 'ZEBRA_SRU_AUTHORITIES_PORT' => '9999', 'KOHA_USER' => 'koha', 'KOHA_GROUP' => 'koha', + 'MERGE_SERVER_HOST' => 'localhost', + 'MERGE_SERVER_PORT' => '11001', + 'PAZPAR2_HOST' => 'localhost', + 'PAZPAR2_PORT' => '11002', ); # set some default configuratio options based on OS @@ -447,9 +457,16 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") { if ($config{'INSTALL_MODE'} ne 'dev') { push @{ $pl_files->{'rewrite-config.PL'} }, ( 'blib/SCRIPT_DIR/koha-zebra-ctl.sh', + 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh', 'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh', ); } + if ($config{'INSTALL_PAZPAR2'} eq 'yes') { + push @{ $pl_files->{'rewrite-config.PL'} }, ( + 'blib/PAZPAR2_CONF_DIR/koha-biblios.xml', + 'blib/PAZPAR2_CONF_DIR/pazpar2.xml' + ); + } $config{'ZEBRA_AUTH_CFG'} = $config{'AUTH_INDEX_MODE'} eq 'dom' ? 'zebra-authorities-dom.cfg' : 'zebra-authorities.cfg'; $config{'AUTH_RETRIEVAL_CFG'} = $config{'AUTH_INDEX_MODE'} eq 'dom' ? 'retrieval-info-auth-dom.xml' : 'retrieval-info-auth-grs1.xml'; @@ -926,6 +943,41 @@ SRU port for authority data?); $config{'ZEBRA_SRU_AUTHORITIES_PORT'} = _get_value('ZEBRA_SRU_AUTHORITIES_PORT', $msg, $defaults->{'ZEBRA_SRU_AUTHORITIES_PORT'}, $valid_values); } + + $msg = q( +Since you've chosen to use Zebra, you can also choose to +install PazPar2, which is a metasearch tool. With PazPar2, +Koha can perform on-the-fly merging of bibliographic +records during searching, allowing for FRBRization of +the results list. + +Install the PazPar2 configuration files?); + $msg .= _add_valid_values_disp('INSTALL_PAZPAR2', $valid_values); + $config{'INSTALL_PAZPAR2'} = _get_value('INSTALL_PAZPAR2', $msg, $defaults->{'INSTALL_PAZPAR2'}, $valid_values); + + if ($config{'INSTALL_PAZPAR2'} eq 'yes') { + $msg = q( +Since you've chosen to configure PazPar2, you must +specify the host and port(s) that PazPar2 +uses: +); + $msg = q( +Zebra bibliographic server host?); + $config{'MERGE_SERVER_HOST'} = _get_value('MERGE_SERVER_HOST', $msg, $defaults->{'MERGE_SERVER_HOST'}, $valid_values); + + $msg = q( +Zebra bibliographic port for PazPar2 to use?); + $config{'MERGE_SERVER_PORT'} = _get_value('MERGE_SERVER_PORT', $msg, $defaults->{'MERGE_SERVER_PORT'}, $valid_values); + + $msg = q( +PazPar2 host?); + $config{'PAZPAR2_HOST'} = _get_value('PAZPAR2_HOST', $msg, $defaults->{'PAZPAR2_HOST'}, $valid_values); + + $msg = q( +PazPar2 port?); + $config{'PAZPAR2_PORT'} = _get_value('PAZPAR2_PORT', $msg, $defaults->{'PAZPAR2_PORT'}, $valid_values); + + } } print "\n\n"; @@ -1010,6 +1062,7 @@ sub get_target_directories { $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib'); $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc'); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb'); + $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man'); @@ -1036,6 +1089,7 @@ sub get_target_directories { $skipdirs{'PERL_MODULE_DIR'} = 1; $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc'); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb'); + $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); $skipdirs{'SCRIPT_DIR'} = 1; @@ -1056,6 +1110,7 @@ sub get_target_directories { $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib'); $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'zebradb'); + $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man'); @@ -1240,8 +1295,12 @@ Zebra's configuration files. sub _update_zebra_conf_target { my $target = "\nupdate_zebra_conf ::\n"; - $target .= "\tumask 022; \$(MOD_INSTALL) \\\n"; + $target .= "\tumask 022; \$(MOD_INSTALL) \\\n"; $target .= "\t\t\$(KOHA_INST_ZEBRA_CONF_DIR) \$(KOHA_DEST_ZEBRA_CONF_DIR) \n"; + $target .= "\t\$(NOECHO) chmod -R u+w \$(KOHA_DEST_ZEBRA_CONF_DIR)\n" unless $^O eq "MSWin32"; + $target .= "\tumask 022; \$(MOD_INSTALL) \\\n"; + $target .= "\t\t\$(KOHA_INST_PAZPAR2_CONF_DIR) \$(KOHA_DEST_PAZPAR2_CONF_DIR) \n"; + $target .= "\t\$(NOECHO) chmod -R u+w \$(KOHA_DEST_PAZPAR2_CONF_DIR)\n" unless $^O eq "MSWin32"; return $target; } diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index 6b2b9a31fd..f60b886c61 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -9,6 +9,17 @@ + +tcp:@:__MERGE_SERVER_PORT__ + + __ZEBRA_DATA_DIR__/biblios + __ZEBRA_CONF_DIR__/zebra-biblios.cfg + __ZEBRA_CONF_DIR__/pqf.properties + + __ZEBRA_DATA_DIR__/biblios @@ -173,5 +184,6 @@ __INTRANET_TMPL_DIR__ __INTRANET_TMPL_DIR__/prog/en/includes/ __LOG_DIR__ + http://__PAZPAR2_HOST__:__PAZPAR2_PORT__/search.pz2 diff --git a/etc/pazpar2/koha-biblios.xml b/etc/pazpar2/koha-biblios.xml index b1a7a003be..dc0fba0a28 100644 --- a/etc/pazpar2/koha-biblios.xml +++ b/etc/pazpar2/koha-biblios.xml @@ -1,4 +1,4 @@ - + @@ -25,6 +25,6 @@ - + diff --git a/etc/pazpar2/pazpar2.xml b/etc/pazpar2/pazpar2.xml index 82818da444..2269647975 100644 --- a/etc/pazpar2/pazpar2.xml +++ b/etc/pazpar2/pazpar2.xml @@ -3,8 +3,8 @@ - - + + diff --git a/misc/bin/koha-pazpar2-ctl.sh b/misc/bin/koha-pazpar2-ctl.sh new file mode 100755 index 0000000000..343a458e69 --- /dev/null +++ b/misc/bin/koha-pazpar2-ctl.sh @@ -0,0 +1,31 @@ +#!/bin/bash +USER=__KOHA_USER__ +GROUP=__KOHA_GROUP__ +NAME=koha-pazpar2-ctl +LOGDIR=__LOG_DIR__ +ERRLOG=$LOGDIR/koha-pazpar2daemon.err +STDOUT=$LOGDIR/koha-pazpar2daemon.log +OUTPUT=$LOGDIR/koha-pazpar2daemon-output.log +PAZPAR2_CONF=__PAZPAR_CONF_DIR__/pazpar2.xml +PAZPAR2SRV=/usr/sbin/pazpar2 + +test -f $PAZPAR2SRV || exit 0 + +case "$1" in + start) + echo "Starting PazPar2 Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- $PAZPAR2SRV -f $PAZPAR2_CONF + ;; + stop) + echo "Stopping PazPar2 Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- $PAZPAR2SRV -f $PAZPAR2_CONF + ;; + restart) + echo "Restarting the PazPar2 Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- $PAZPAR2SRV -f $PAZPAR2_CONF + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart}" + exit 1 + ;; +esac diff --git a/rewrite-config.PL b/rewrite-config.PL index dbee4dac0d..82524af0df 100644 --- a/rewrite-config.PL +++ b/rewrite-config.PL @@ -100,6 +100,7 @@ $prefix = $ENV{'INSTALL_BASE'} || "/usr"; '__PERL_MODULE_DIR__' => ($ENV{'INSTALLSITELIB'} || sprintf($prefix."/lib/perl5/site_perl/%vd",$^V))."/koha", '__KOHA_CONF_DIR__' => "$prefix/etc/koha", '__ZEBRA_CONF_DIR__' => "$prefix/etc/koha/zebradb", + '__PAZPAR2_CONF_DIR__' => "$prefix/etc/koha/pazpar2", '__MISC_DIR__' => "$prefix/misc", '__SCRIPT_DIR__' => "$prefix/bin", '__MAN_DIR__' => "$prefix/man", @@ -111,6 +112,10 @@ $prefix = $ENV{'INSTALL_BASE'} || "/usr"; '__ZEBRA_LANGUAGE__' => 'en', '__ZEBRA_AUTH_CFG__' => 'zebra-authorities.cfg', '__AUTH_RETRIEVAL_CFG__' => 'retrieval-info-auth-grs1.xml', + "__MERGE_SERVER_HOST__" => $myhost, + "__MERGE_SERVER_PORT__" => '11001', + "__PAZPAR2_HOST__" => $myhost, + "__PAZPAR2_PORT__" => '11002', ); # Override configuration from the environment -- 2.39.5