From b2649cbcbacbabc7cf56125a72db8db43eece7db Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 12 Aug 2014 10:50:46 -0300 Subject: [PATCH] Bug 12750: koha-create should be able to configure the Z39.50/SRU server This patch adds two parameters to the koha-create command: --enable-sru: makes the koha-create script enabled the SRU server for the created instance --sru-port: lets the user specify a desired port for the SRU server to listen at. It defaults to 7090 To test: - Apply the patch on top of master - Build your own package and install / can be tested just using the koha-create command on a 3.16+ packages install - Create an instance as usual (i.e. without --enable-sru and --sru-port) => SUCCESS: The instance is created, the publicserver sections are both commented out. The first publicserver section has 7090 set as the listening port. - Create an instance as usual, passing --sru-port 456 => SUCCESS: The instance is created, the port is set but the publicserver sections are commented out - Create an instance with --enable-sru (with and without --sru-port) => SUCCESS: Verify the instance is created as expected, with the SRU server enabled (port 7090 if no --sru-port passed, the one we chose otherwise). - Verify that the docs also talk about this new parameters addition. - Sign off :-D Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Jesse Maseto Signed-off-by: Brendan Gallagher Signed-off-by: Robin Sheat Signed-off-by: Tomas Cohen Arazi --- debian/docs/koha-create.xml | 16 ++++++++++++ debian/scripts/koha-create | 34 +++++++++++++++++++++++++- debian/templates/koha-conf-site.xml.in | 12 ++++----- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/debian/docs/koha-create.xml b/debian/docs/koha-create.xml index 7fb7956043..d3f186b351 100644 --- a/debian/docs/koha-create.xml +++ b/debian/docs/koha-create.xml @@ -37,6 +37,8 @@ /path/to/passwd database n + + port | instancename @@ -151,6 +153,20 @@ + + + + Enable the Z39.50/SRU server for the created instance. + + + + + + + Specifiy a for the Z39.50/SRU server to listen on. + + + , diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 6891ac1ffd..19b3d5c660 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -60,6 +60,9 @@ Options: --use-memcached Set the instance to make use of memcache. --memcached-servers str Set a comma-separated list of host:port memcached servers. --memcached-prefix str Set the desired prefix for the instance memcached namespace. + --enable-sru Enable the Z39.50/SRU server (default: disabled). + --sru-port Specifiy a TCP port number for the Z39.50/SRU server + to listen on. (default: 7090). --defaultsql some.sql Specify a default SQL file to be loaded on the DB. --configfile cfg_file Specify an alternate config file for reading default values. --passwdfile passwd Specify an alternate passwd file. @@ -87,6 +90,9 @@ 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/__SRU_BIBLIOS_PORT__/$SRU_SERVER_PORT/g" \ + -e "s/__START_SRU_PUBLICSERVER__/$START_SRU_PUBLICSERVER/g" \ + -e "s/__END_SRU_PUBLICSERVER__/$END_SRU_PUBLICSERVER/g" \ -e "s/__BIBLIOS_INDEXING_MODE__/$BIBLIOS_INDEXING_MODE/g" \ -e "s/__AUTHORITIES_INDEXING_MODE__/$AUTHORITIES_INDEXING_MODE/g" \ -e "s/__ZEBRA_BIBLIOS_CFG__/$ZEBRA_BIBLIOS_CFG/g" \ @@ -280,6 +286,17 @@ set_memcached() } +enable_sru_server() +{ + # remove the commenting symbols + START_SRU_PUBLICSERVER="" + END_SRU_PUBLICSERVER="" + if [ "$SRU_SERVER_PORT" = "" ]; then + # --sru-port not passed, use the default + SRU_SERVER_PORT=$DEFAULT_SRU_SERVER_PORT + fi +} + # Set defaults and read config file, if it exists. DOMAIN="" OPACPORT="80" @@ -302,6 +319,14 @@ MEMCACHED_PREFIX="" DEFAULT_MEMCACHED_SERVERS="127.0.0.1:11211" DEFAULT_MEMCACHED_PREFIX="koha_" +# SRU server variables +ENABLE_SRU="no" +SRU_SERVER_PORT="" +# hardcoded default SRU server port +DEFAULT_SRU_SERVER_PORT="7090" +START_SRU_PUBLICSERVER="" + # Indexing mode variables (default is DOM) BIBLIOS_INDEXING_MODE="dom" AUTHORITIES_INDEXING_MODE="dom" @@ -318,7 +343,7 @@ fi [ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) -TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -369,6 +394,10 @@ while true ; do CLO_DATABASE="$2" ; shift 2 ;; -a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;; + --enable-sru) + ENABLE_SRU="yes" ; shift ;; + --sru-port) + SRU_SERVER_PORT="$2" ; shift 2 ;; -h|--help) usage ; exit 0 ;; --) @@ -417,6 +446,9 @@ fi set_biblios_indexing_mode $BIBLIOS_INDEXING_MODE $ZEBRA_MARC_FORMAT +if [ "$ENABLE_SRU" != "no" ]; then + enable_sru_server +fi if [ "$CLO_AUTHORITIES_INDEXING_MODE" != "" ]; then AUTHORITIES_INDEXING_MODE=$CLO_AUTHORITIES_INDEXING_MODE diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index 1892960758..26f4e5086f 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -6,9 +6,9 @@ - +__START_SRU_PUBLICSERVER__ +tcp:@:__SRU_BIBLIOS_PORT__ +__END_SRU_PUBLICSERVER__ - +__START_SRU_PUBLICSERVER__ /var/lib/koha/__KOHASITE__/biblios /etc/koha/sites/__KOHASITE__/__ZEBRA_BIBLIOS_CFG__ @@ -245,7 +245,7 @@ kohauser __ZEBRA_PASS__ ---> +__END_SRU_PUBLICSERVER__ mysql -- 2.39.5