From b438573c0f40cadea0b6fe097154a0d385034dc0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 8 Aug 2013 15:15:53 -0300 Subject: [PATCH] Bug 8507: koha-create should be updated to use DOM indexing for bib This patch makes the koha-create script install the file zebra-biblios-dom.cfg with the proper string substitutions inside on the new instance. It also adds two option switches that control the indexing mode for the instance: --biblio-idx {dom|grs1} --auth-idx {dom|grs1} DOM indexing is set as the default for both authorities and bibliographic records. To test: - Apply the patch - Build your own packages and install them on a test server a) Create a new instance without using the new switches like: $ koha-create --create-db domtest - Check there's a file /etc/koha/sites/domtest/zebra-biblios-dom.cfg - Check that /etc/koha/sites/domtest/koha-conf.xml points to: * zebra-biblios-dom.cfg (biblioserver section) * zebra-biblios-dom.cfg (publicserver section) * zebra-authorities-dom.cfg (authorityserver section) - Success means the new default is DOM b) Play with the 4 possible combination of option switches $ koha-create --create-db --auth-idx grs1 --biblio-idx grs1 domtest $ koha-create --create-db --auth-idx grs1 --biblio-idx dom domtest $ koha-create --create-db --auth-idx dom --biblio-idx grs1 domtest $ koha-create --create-db --auth-idx dom --biblio-idx dom domtest - Check the koha-conf.xml file reflects the chosen options. c) Run $ koha-create --help - It should advertise this addition accordingly. d) Run $ man koha-create - Man page for koha-create should provide good information on the new switches behaviour Regards To+ Edit: Fixed a small typo that prevented DOM indexing to be set for authorities. Sponsored-by: Universidad Nacional de Cordoba --- debian/docs/koha-create.xml | 16 +++++++++ debian/scripts/koha-create | 45 +++++++++++++++++++++++++- debian/templates/koha-conf-site.xml.in | 6 ++-- debian/templates/zebra-biblios-dom-site.cfg.in | 22 ++++++------- 4 files changed, 74 insertions(+), 15 deletions(-) diff --git a/debian/docs/koha-create.xml b/debian/docs/koha-create.xml index 491da62..31c168a 100644 --- a/debian/docs/koha-create.xml +++ b/debian/docs/koha-create.xml @@ -27,6 +27,8 @@ ||| marc21|normarc|unimarc en|es|fr|nb|ru|uk + dom|grs1 + dom|grs1 /path/to/some.sql /path/to/config /path/to/passwd @@ -109,6 +111,20 @@ + + + + Specified the desired indexing mode for authority records. Valid options are (default) and . + + + + + + + Specified the desired indexing mode for bibliographic records. Valid options are (default) and . + + + diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index a0a830a..3bb49fc 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -22,6 +22,7 @@ set -e usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \ [--marcflavor marc21|normarc|unimarc] \ [--zebralang en|es|fr|nb|ru|uk] \ + [--auth-idx dom|grs1] [--biblio-idx dom|grs1] \ [--defaultsql /path/to/some.sql] \ [--configfile /path/to/config] [--passwdfile /path/to/passwd] \ [--database database] [--adminuser n] instancename" @@ -45,6 +46,8 @@ generate_config_file() { -e "s/__ZEBRA_PASS__/$zebrapwd/g" \ -e "s/__ZEBRA_MARC_FORMAT__/$ZEBRA_MARC_FORMAT/g" \ -e "s/__ZEBRA_LANGUAGE__/$ZEBRA_LANGUAGE/g" \ + -e "s/__BIBLIO_INDEXING__/$BIBLIO_INDEXING/g" \ + -e "s/__AUTHORITY_INDEXING__/$AUTHORITY_INDEXING/g" \ -e "s/__DB_NAME__/$mysqldb/g" \ -e "s/__DB_HOST__/$mysqlhost/g" \ -e "s/__DB_USER__/$mysqluser/g" \ @@ -75,6 +78,40 @@ getinstancemysqldatabase() { xmlstarlet sel -t -v 'yazgfs/config/database' "/etc/koha/sites/$1/koha-conf.xml" } +set_authority_indexing() +{ + indexing_mode=$1 + + case $indexing_mode in + "grs1") + AUTHORITY_INDEXING="" + ;; + "dom") + AUTHORITY_INDEXING="-dom" + ;; + *) + die "Error: '$indexing_mode' is not a valid indexing mode for authority records." + ;; + esac +} + +set_biblio_indexing() +{ + indexing_mode=$1 + + case $indexing_mode in + "grs1") + BIBLIO_INDEXING="" + ;; + "dom") + BIBLIO_INDEXING="-dom" + ;; + *) + die "Error: '$indexing_mode' is not a valid indexing mode for bibliographic records." + ;; + esac +} + # Set defaults and read config file, if it exists. DOMAIN="" OPACPORT="80" @@ -86,6 +123,8 @@ INTRASUFFIX="" DEFAULTSQL="" ZEBRA_MARC_FORMAT="marc21" ZEBRA_LANGUAGE="en" +BIBLIO_INDEXING="-dom" +AUTHORITY_INDEXING="-dom" ADMINUSER="1" PASSWDFILE="/etc/koha/passwd" if [ -e /etc/koha/koha-sites.conf ] @@ -95,7 +134,7 @@ fi [ $# -ge 2 ] && [ $# -le 16 ] || die $usage -TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,marcflavor:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser: \ +TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser: \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -115,6 +154,8 @@ while true ; do -u|--use-db) op=use ; shift ;; -m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; -l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; + --auth-idx) set_authority_indexing "$2" ; shift 2 ;; + --biblio-idx) set_biblio_indexing "$2" ; shift 2 ;; -d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; -f|--configfile) configfile="$2" ; shift 2 ;; -s|--passwdfile) CLO_PASSWDFILE="$2" ; shift 2 ;; @@ -261,6 +302,8 @@ eof # Generate and install Zebra config files. generate_config_file zebra-biblios-site.cfg.in \ "/etc/koha/sites/$name/zebra-biblios.cfg" + generate_config_file zebra-biblios-dom-site.cfg.in \ + "/etc/koha/sites/$name/zebra-biblios-dom.cfg" generate_config_file zebra-authorities-site.cfg.in \ "/etc/koha/sites/$name/zebra-authorities.cfg" generate_config_file zebra-authorities-dom-site.cfg.in \ diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index ab8aff5..64235a6 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -26,7 +26,7 @@ /var/lib/koha/__KOHASITE__/biblios - /etc/koha/sites/__KOHASITE__/zebra-biblios.cfg + /etc/koha/sites/__KOHASITE__/zebra-biblios__BIBLIO_INDEXING__.cfg /etc/koha/zebradb/pqf.properties @@ -102,7 +102,7 @@ /var/lib/koha/__KOHASITE__/authorities - /etc/koha/sites/__KOHASITE__/zebra-authorities-dom.cfg + /etc/koha/sites/__KOHASITE__/zebra-authorities__AUTHORITY_INDEXING__.cfg /etc/koha/zebradb/pqf.properties @@ -176,7 +176,7 @@ /var/lib/koha/__KOHASITE__/biblios - /etc/koha/sites/__KOHASITE__/zebra-biblios.cfg + /etc/koha/sites/__KOHASITE__/zebra-biblios__BIBLIO_INDEXING__.cfg /etc/koha/zebradb/pqf.properties diff --git a/debian/templates/zebra-biblios-dom-site.cfg.in b/debian/templates/zebra-biblios-dom-site.cfg.in index a748ddd..88d0d6d 100644 --- a/debian/templates/zebra-biblios-dom-site.cfg.in +++ b/debian/templates/zebra-biblios-dom-site.cfg.in @@ -3,7 +3,7 @@ # $Id: zebra.cfg,v 1.1.2.2 2006/05/09 12:03:16 rangi Exp $ # # Where are the config files located? -profilePath:__ZEBRA_CONF_DIR__/biblios/etc:__ZEBRA_CONF_DIR__/etc:__ZEBRA_CONF_DIR__/marc_defs/__ZEBRA_MARC_FORMAT__/biblios:__ZEBRA_CONF_DIR__/lang_defs/__ZEBRA_LANGUAGE__:__ZEBRA_CONF_DIR__/xsl +profilePath:/etc/koha/zebradb/biblios/etc:/etc/koha/zebradb/etc:/etc/koha/zebradb/marc_defs/__ZEBRA_MARC_FORMAT__/biblios:/etc/koha/zebradb/lang_defs/__ZEBRA_LANGUAGE__:/etc/koha/zebradb/xsl # modulePath - where to look for loadable zebra modules modulePath: /usr/lib/idzebra-2.0/modules @@ -21,9 +21,9 @@ attset: gils.att # http://www.indexdata.dk/zebra/doc/zebra-cfg.tkl # http://www.indexdata.dk/zebra/doc/grs.tkl -recordtype: dom.__ZEBRA_CONF_DIR__/biblios/etc/dom-config.xml -marcxml.recordtype: dom.__ZEBRA_CONF_DIR__/biblios/etc/dom-config.xml -iso2709.recordtype: dom.__ZEBRA_CONF_DIR__/biblios/etc/dom-config-marc.xml +recordtype: dom./etc/koha/zebradb/biblios/etc/dom-config.xml +marcxml.recordtype: dom./etc/koha/zebradb/biblios/etc/dom-config.xml +iso2709.recordtype: dom./etc/koha/zebradb/biblios/etc/dom-config-marc.xml recordId: (bib1,Local-number) storeKeys:1 @@ -31,18 +31,18 @@ storeData:1 # Lock File Area -lockDir: __ZEBRA_LOCK_DIR__/biblios +lockDir: /var/lock/koha/__KOHASITE__/biblios perm.anonymous:ar -perm.__ZEBRA_USER__:rw -passwd: __ZEBRA_CONF_DIR__/etc/passwd -register: __ZEBRA_DATA_DIR__/biblios/register:20G -shadow: __ZEBRA_DATA_DIR__/biblios/shadow:20G +perm.kohauser:rw +passwd: /etc/koha/sites/__KOHASITE__/zebra.passwd +register: /var/lib/koha/__KOHASITE__/biblios/register:20G +shadow: /var/lib/koha/__KOHASITE__/biblios/shadow:20G # Temp File area for result sets -setTmpDir: __ZEBRA_DATA_DIR__/biblios/tmp +setTmpDir: /var/lib/koha/__KOHASITE__/biblios/tmp # Temp File area for index program -keyTmpDir: __ZEBRA_DATA_DIR__/biblios/key +keyTmpDir: /var/lib/koha/__KOHASITE__/biblios/key # Approx. Memory usage during indexing memMax: 50M -- 1.8.1.2