Bugzilla – Attachment 86362 Details for
Bug 13937
Add an Elasticsearch-compatible Z39.50/SRU daemon
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13937: Add support for Z39.50 responder to the Debian scripts
Bug-13937-Add-support-for-Z3950-responder-to-the-D.patch (text/plain), 18.30 KB, created by
Ere Maijala
on 2019-03-08 10:11:35 UTC
(
hide
)
Description:
Bug 13937: Add support for Z39.50 responder to the Debian scripts
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2019-03-08 10:11:35 UTC
Size:
18.30 KB
patch
obsolete
>From 98222553c690d1dd66262e8b7a2271a49473880b Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Fri, 11 Jan 2019 11:27:56 +0200 >Subject: [PATCH] Bug 13937: Add support for Z39.50 responder to the Debian > scripts > >--- > debian/koha-common.init | 20 ++ > debian/scripts/koha-create | 5 +- > debian/scripts/koha-functions.sh | 23 ++ > debian/scripts/koha-list | 43 +++- > debian/scripts/koha-z3950-responder | 354 ++++++++++++++++++++++++++++ > etc/z3950/config.xml | 1 + > misc/z3950_responder.pl | 5 - > 7 files changed, 443 insertions(+), 8 deletions(-) > create mode 100755 debian/scripts/koha-z3950-responder > >diff --git a/debian/koha-common.init b/debian/koha-common.init >index 99df08b26b..aeb526f2b6 100755 >--- a/debian/koha-common.init >+++ b/debian/koha-common.init >@@ -60,6 +60,7 @@ do_start() > koha-zebra --start $(koha-list --enabled) > koha-sip --start $(koha-list --enabled --sip) > koha-plack --start $(koha-list --enabled --plack) >+ koha-z3950-responder --start $(koha-list --enabled --z3950) > > if [ "$USE_INDEXER_DAEMON" = "yes" ]; then > koha-indexer --start --quiet $(koha-list --enabled) >@@ -148,6 +149,24 @@ plack_status() > done > } > >+# >+# Function that shows the status of the Z39.50/SRU server daemon for >+# enabled instances >+# >+z3950_status() >+{ >+ for instance in $(koha-list --enabled --z3950); do >+ >+ log_daemon_msg "Z39.50/SRU daemon running for instance ${instance}" >+ >+ if is_z3950_running $instance ; then >+ log_end_msg 0 >+ else >+ log_end_msg 1 >+ fi >+ done >+} >+ > case "$1" in > start) > [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" >@@ -190,6 +209,7 @@ case "$1" in > zebra_status > sip_status > plack_status >+ z3950_status > ;; > *) > echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 >diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create >index 5e60f7cd77..9feb8031b7 100755 >--- a/debian/scripts/koha-create >+++ b/debian/scripts/koha-create >@@ -55,8 +55,9 @@ Options: > values are cs, en (default), es, fr, gr, nb, ru and uk. > --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 >+ --enable-sru Enable the Z39.50/SRU server in Zebra search engine >+ (default: disabled). >+ --sru-port Specify a TCP port number for Zebra's 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. >diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh >index 3a04db7851..add64d8667 100755 >--- a/debian/scripts/koha-functions.sh >+++ b/debian/scripts/koha-functions.sh >@@ -230,6 +230,29 @@ is_plack_running() > fi > } > >+is_z3950_enabled() >+{ >+ local instancename=$1 >+ >+ if [ -e /etc/koha/sites/$instancename/z3950/config.xml ]; then >+ return 0 >+ else >+ return 1 >+ fi >+} >+ >+is_z3950_running() >+{ >+ local instancename=$1 >+ >+ if start-stop-daemon --pidfile "/var/run/koha/${instancename}/z3950-responder.pid" \ >+ --status ; then >+ return 0 >+ else >+ return 1 >+ fi >+} >+ > adjust_paths_dev_install() > { > # Adjust KOHA_HOME, PERL5LIB for dev installs, as indicated by >diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list >index 0dd72e1a94..a88d37b892 100755 >--- a/debian/scripts/koha-list >+++ b/debian/scripts/koha-list >@@ -39,6 +39,7 @@ show_instances() > if instance_filter_email $instance $show_email && \ > instance_filter_letsencrypt $instance $show_letsencrypt && \ > instance_filter_plack $instance $show_plack && \ >+ instance_filter_z3950 $instance $show_z3950 && \ > instance_filter_sip $instance $show_sip; then > echo $instance > fi ;; >@@ -47,6 +48,7 @@ show_instances() > if instance_filter_email $instance $show_email && \ > instance_filter_letsencrypt $instance $show_letsencrypt && \ > instance_filter_plack $instance $show_plack && \ >+ instance_filter_z3950 $instance $show_z3950 && \ > instance_filter_sip $instance $show_sip; then > echo $instance > fi >@@ -56,6 +58,7 @@ show_instances() > if instance_filter_email $instance $show_email && \ > instance_filter_letsencrypt $instance $show_letsencrypt && \ > instance_filter_plack $instance $show_plack && \ >+ instance_filter_z3950 $instance $show_z3950 && \ > instance_filter_sip $instance $show_sip; then > echo $instance > fi >@@ -153,6 +156,28 @@ instance_filter_email() > return 1 > } > >+instance_filter_z3950() >+{ >+ local instancename=$1 >+ local show_z3950=$2; >+ >+ case $show_z3950 in >+ "all") >+ return 0 ;; >+ "enabled") >+ if is_z3950_enabled $instancename; then >+ return 0 >+ fi ;; >+ "disabled") >+ if ! is_z3950_enabled $instancename; then >+ return 0 >+ fi ;; >+ esac >+ >+ # Didn't match any criteria >+ return 1 >+} >+ > set_show() > { > local show_param=$1 >@@ -208,6 +233,17 @@ set_show_sip() > fi > } > >+set_show_z3950() >+{ >+ local z3950_param=$1 >+ >+ if [ "$show_z3950" = "all" ]; then >+ show_z3950=$z3950_param >+ else >+ die "Error: --z3950 and --noz3950 are mutually exclusive." >+ fi >+} >+ > usage() > { > local scriptname=$0 >@@ -228,6 +264,8 @@ Options: > --noplack Show instances with Plack disabled > --letsencrypt Show instances with letsencrypt enabled > --noletsencrypt Show instances with letsencrypt disabled >+ --z3950 Show instances with Z39.50/SRU enabled >+ --noz3950 Show instances with Z39.50/SRU disabled > --help | -h Show this help > > The filtering options can be combined, and you probably want to do this >@@ -240,8 +278,9 @@ show_email="all" > show_sip="all" > show_plack="all" > show_letsencrypt="all" >+show_z3950="all" > >-args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt -o h -n $0 -- "$@") >+args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt,z3950,noz3950 -o h -n $0 -- "$@") > set -- $args > > while [ ! -z "$1" ] >@@ -256,6 +295,8 @@ do > --noplack) set_show_plack "disabled" ;; > --letsencrypt) set_show_letsencrypt "enabled" ;; > --noletsencrypt) set_show_letsencrypt "disabled" ;; >+ --z3950) set_show_z3950 "enabled" ;; >+ --noz3950) set_show_z3950 "disabled" ;; > --enabled) set_show "enabled" ;; > --disabled) set_show "disabled" ;; > *) break;; >diff --git a/debian/scripts/koha-z3950-responder b/debian/scripts/koha-z3950-responder >new file mode 100755 >index 0000000000..b364acd78e >--- /dev/null >+++ b/debian/scripts/koha-z3950-responder >@@ -0,0 +1,354 @@ >+#!/bin/bash >+# >+# Copyright 2015 Theke Solutions >+# Copyright 2016 Koha-Suomi >+# Copyright 2018 The National Library of Finland, University of Helsinki >+# >+# This file is part of Koha. >+# >+# This program is free software: you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation, either version 3 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program. If not, see <http://www.gnu.org/licenses/>. >+ >+set -e >+ >+. /lib/lsb/init-functions >+ >+# Read configuration variable file if it is present >+[ -r /etc/default/koha-common ] && . /etc/default/koha-common >+ >+# include helper functions >+if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then >+ . "/usr/share/koha/bin/koha-functions.sh" >+else >+ echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 >+ exit 1 >+fi >+ >+usage() >+{ >+ local scriptname=$(basename $0) >+ >+ cat <<EOF >+$scriptname >+ >+This script lets you manage the Z39.50/SRU daemons for your Koha instances. >+ >+Usage: >+$scriptname --start|--stop|--restart [--quiet|-q] instancename1 [instancename2...] >+$scriptname --enable|--disable instancename1 [instancename2] >+$scriptname -h|--help >+ >+ --start Start the Z39.50/SRU daemon for the specified instances >+ --stop Stop the Z39.50/SRU daemon for the specified instances >+ --restart Restart the Z39.50/SRU daemon for the specified instances >+ --enable Enable Z39.50/SRU for the specified instances >+ --disable Disable Z39.50/SRU for the specified instances >+ --debugger Enable running Z39.50/SRU in debug mode >+ --debugger-key Specify the key the IDE is expecting >+ --debugger-location Specify the host:port for your debugger tool (defaults >+ to localhost:9000) >+ --debugger-path Specify the path for the debugger library >+ --quiet|-q Make the script quiet about non existent instance names >+ (useful for calling from another scripts). >+ --help|-h Display this help message >+ >+EOF >+} >+ >+start_z3950() >+{ >+ local instancename=$1 >+ >+ local PIDFILE="/var/run/koha/${instancename}/z3950-responder.pid" >+ local NAME="${instancename}-koha-z3950-responder" >+ local CONFIGDIR="/etc/koha/z3950" >+ >+ if [ -e "/etc/koha/sites/${instancename}/z3950/config.xml" ]; then >+ #Â pick instance-specific config dir >+ CONFIGDIR="/etc/koha/sites/${instancename}/z3950" >+ fi #Â else stick with the default one >+ >+ _check_and_fix_perms $instancename >+ >+ instance_user="${instancename}-koha" >+ >+ daemonize="-D -d ${instancename}-koha-z3950" >+ logging="-l /var/log/koha/${instancename}/z3950.log" >+ >+ if [ "$DEV_INSTALL" = "1" ]; then >+ LIBDIR=$KOHA_HOME >+ else >+ LIBDIR=$KOHA_HOME/lib >+ fi >+ >+ Z3950RESPONDER="/usr/bin/perl $LIBDIR/misc/z3950_responder.pl" >+ if [ "$debug_mode" = "yes" ]; then >+ if [ "$DEV_INSTALL" = "1" ]; then >+ warn "Not a dev install, disabling debug mode" >+ else >+ environment="development" >+ daemonize="" >+ logging="" # remote debugger takes care >+ Z3950RESPONDER="/usr/bin/perl -d ${LIBDIR}/misc/z3950_responder.pl" >+ fi >+ fi >+ >+ Z3950OPTS="-c ${CONFIGDIR} \ >+ -u ${instance_user} \ >+ -p ${PIDFILE} ${daemonize} ${logging}" >+ >+ if ! is_z3950_running ${instancename}; then >+ export KOHA_CONF="/etc/koha/sites/${instancename}/koha-conf.xml" >+ >+ log_daemon_msg "Starting Z39.50/SRU daemon for ${instancename}" >+ >+ # Change to the instance's user dir >+ current_dir=$(pwd) >+ eval cd ~$instance_user >+ >+ if ${Z3950RESPONDER} ${Z3950OPTS}; then >+ log_end_msg 0 >+ else >+ log_end_msg 1 >+ fi >+ # Go back to the original dir >+ cd "$current_dir" >+ >+ else >+ log_daemon_msg "Error: Z39.50/SRU already running for ${instancename}" >+ log_end_msg 1 >+ fi >+} >+ >+stop_z3950() >+{ >+ local instancename=$1 >+ >+ local PIDFILE="/var/run/koha/${instancename}/z3950-responder.pid" >+ >+ if is_z3950_running ${instancename}; then >+ >+ log_daemon_msg "Stopping Z39.50/SRU daemon for ${instancename}" >+ >+ if start-stop-daemon --pidfile ${PIDFILE} --stop --retry=TERM/30/KILL/5; then >+ log_end_msg 0 >+ else >+ log_end_msg 1 >+ fi >+ else >+ log_daemon_msg "Error: Z39.50/SRU not running for ${instancename}" >+ log_end_msg 1 >+ fi >+} >+ >+restart_z3950() >+{ >+ local instancename=$1 >+ >+ local PIDFILE="/var/run/koha/${instancename}/z3950.pid" >+ >+ if is_z3950_running ${instancename}; then >+ >+ log_daemon_msg "Restarting Z39.50/SRU daemon for ${instancename}" >+ >+ if stop_z3950 $instancename && start_z3950 $instancename; then >+ log_end_msg 0 >+ else >+ log_end_msg 1 >+ fi >+ else >+ log_daemon_msg "Error: Z39.50/SRU not running for ${instancename}" >+ log_end_msg 1 >+ fi >+} >+ >+enable_z3950() >+{ >+ local instancename=$1 >+ >+ if [ ! -e /etc/koha/sites/${instancename}/koha-conf.xml ] ; >+ then >+ echo "No such instance: ${instancename}" > /dev/stderr >+ return 1 >+ fi >+ >+ local configdir=/etc/koha/sites/${instancename}/z3950 >+ if [ -e ${configdir}/config.xml ] >+ then >+ [ "${quiet}" != "yes" ] && warn "Z39.50/SRU already enabled for $name" >+ return 1 >+ fi >+ >+ if [ ! -e ${configdir} ] >+ then >+ mkdir ${configdir} >+ fi >+ cp /etc/koha/z3950/* ${configdir}/ >+ chown ${name}-koha:${name}-koha ${configdir}/* >+ chmod 600 ${configdir}/* >+ >+ [ "${quiet}" != "yes" ] && warn "Z39.50/SRU enabled for $name - edit files in ${configdir} to configure" >+ return 0 >+} >+ >+disable_z3950() >+{ >+ local instancename=$1 >+ >+ if is_z3950_enabled $instancename; then >+ local configdir=/etc/koha/sites/${instancename}/z3950 >+ mv ${configdir} ${configdir}.`date +%F_%T` >+ [ "${quiet}" != "yes" ] && warn "Z39.50/SRU disabled for ${instancename}" >+ return 0 >+ else >+ [ "${quiet}" != "yes" ] && warn "Z39.50/SRU already disabled for ${instancename}" >+ return 1 >+ fi >+} >+ >+_check_and_fix_perms() >+{ >+ local instance=$1 >+ >+ local files="/var/log/koha/${instance}/z3950.log" >+ >+ for file in ${files} >+ do >+ if [ ! -e "${file}" ]; then >+ touch ${file} >+ fi >+ chown "${instance}-koha":"${instance}-koha" ${file} >+ done >+} >+ >+set_action() >+{ >+ if [ "$op" = "" ]; then >+ op=$1 >+ else >+ die "Error: only one action can be specified." >+ fi >+} >+ >+op="" >+quiet="no" >+debug_mode="no" >+debugger_key="" >+debugger_location="localhost:9000" >+debugger_path="" >+ >+# Read command line parameters >+while [ $# -gt 0 ]; do >+ >+ case "$1" in >+ -h|--help) >+ usage ; exit 0 ;; >+ -q|--quiet) >+ quiet="yes" >+ shift ;; >+ --start) >+ set_action "start" >+ shift ;; >+ --stop) >+ set_action "stop" >+ shift ;; >+ --restart) >+ set_action "restart" >+ shift ;; >+ --enable) >+ set_action "enable" >+ shift ;; >+ --disable) >+ set_action "disable" >+ shift ;; >+ --debugger) >+ debug_mode="yes" >+ shift ;; >+ --debugger-key) >+ debugger_key="$2" >+ shift 2 ;; >+ --debugger-location) >+ debugger_location="$2" >+ shift 2 ;; >+ --debugger-path) >+ debugger_path="$2" >+ shift 2 ;; >+ -*) >+ die "Error: invalid option switch ($1)" ;; >+ *) >+ # We expect the remaining stuff are the instance names >+ break ;; >+ esac >+ >+done >+ >+if [ $# -gt 0 ]; then >+ # We have at least one instance name >+ for name in "$@"; do >+ >+ if is_instance $name; then >+ >+ adjust_paths_dev_install $name >+ export DEV_INSTALL >+ export KOHA_HOME >+ PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer >+ # If debug mode is enabled, add the debugger lib path >+ # to PERL5LIB if appropriate >+ if [ "$debug_mode" = "yes" ]; then >+ if [ "$debugger_path" != "" ]; then >+ PERL5LIB="${debugger_path}":$PERL5LIB >+ fi >+ export PERL5DB="BEGIN { require q(${debugger_path}/perl5db.pl) }" >+ export PERLDB_OPTS="RemotePort=${debugger_location} async=1 LogFile=/var/log/koha/${name}/z3950-debug.log" >+ export DBGP_IDEKEY=${debugger_key} >+ export PERL5OPT="-d" >+ fi >+ >+ export PERL5LIB >+ >+ case $op in >+ "start") >+ start_z3950 $name >+ ;; >+ "stop") >+ stop_z3950 $name >+ ;; >+ "restart") >+ restart_z3950 $name >+ ;; >+ "enable") >+ enable_z3950 $name >+ ;; >+ "disable") >+ disable_z3950 $name >+ ;; >+ *) >+ usage >+ ;; >+ esac >+ >+ else >+ if [ "$quiet" = "no" ]; then >+ log_daemon_msg "Error: Invalid instance name $name" >+ log_end_msg 1 >+ fi >+ fi >+ >+ done >+else >+ if [ "$quiet" = "no" ]; then >+ warn "Error: you must provide at least one instance name" >+ fi >+fi >+ >+exit 0 >diff --git a/etc/z3950/config.xml b/etc/z3950/config.xml >index bb9c2a6eff..7433851f8b 100644 >--- a/etc/z3950/config.xml >+++ b/etc/z3950/config.xml >@@ -1,4 +1,5 @@ > <yazgfs> >+ <listen id="public">tcp:@:2100</listen> > <server> > <cql2rpn>pqf.properties</cql2rpn> > <explain xmlns="http://explain.z3950.org/dtd/2.0/"> >diff --git a/misc/z3950_responder.pl b/misc/z3950_responder.pl >index e6fa623a62..871fca676f 100755 >--- a/misc/z3950_responder.pl >+++ b/misc/z3950_responder.pl >@@ -156,11 +156,6 @@ GetOptions( > pod2usage(1) if $help; > pod2usage( -verbose => 2 ) if $man; > >-if (!@ARGV || $ARGV[-1] =~ /^-/) { >- # No bind address specified. Use @:2100 by default. >- push(@ARGV, '@:2100'); >-} >- > # If config_dir is not defined, default to z3950 under the Koha config directory > if (!$config_dir) { > (undef, $config_dir) = fileparse(Koha::Config->guess_koha_conf); >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13937
:
46369
|
47417
|
47418
|
47419
|
53503
|
58122
|
58125
|
58126
|
59443
|
59444
|
60735
|
60736
|
60737
|
60738
|
66943
|
66944
|
66945
|
66946
|
69139
|
82562
|
82563
|
82564
|
82565
|
82566
|
82567
|
82589
|
82590
|
82591
|
82592
|
82593
|
82594
|
82595
|
82660
|
82661
|
82662
|
82663
|
82664
|
82665
|
82666
|
82667
|
83780
|
83781
|
83782
|
83783
|
83784
|
83785
|
83786
|
83787
|
83788
|
83789
|
83951
|
83952
|
83953
|
83954
|
83955
|
83956
|
83957
|
83958
|
83959
|
84050
|
84051
|
84052
|
84053
|
84054
|
84055
|
84056
|
84057
|
84058
|
84059
|
84062
|
84063
|
84064
|
84065
|
84066
|
84067
|
84068
|
84069
|
84072
|
84073
|
85112
|
86353
|
86354
|
86355
|
86356
|
86357
|
86358
|
86359
|
86360
|
86361
|
86362
|
86363
|
86364
|
88907
|
88908
|
88909
|
88910
|
88911
|
88912
|
88913
|
88914
|
88915
|
88916
|
88917
|
88918
|
91728
|
91729
|
91730
|
91731
|
91732
|
91733
|
91734
|
91735
|
91736
|
91737
|
91738
|
91739
|
91740
|
93913
|
94097
|
94109
|
94110
|
94209
|
94616
|
94647