@@ -, +, @@ -q to make koha-inxeder quiet (useful for the init script). --- debian/docs/koha-common.xml | 7 ++ debian/docs/koha-indexer.xml | 86 ++++++++++++++ debian/koha-common.cron.d | 1 + debian/koha-common.default | 21 ++++ debian/koha-common.init | 34 +++--- debian/koha-common.install | 1 + debian/scripts/koha-create | 3 + debian/scripts/koha-indexer | 277 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 411 insertions(+), 19 deletions(-) create mode 100644 debian/docs/koha-indexer.xml create mode 100644 debian/koha-common.default create mode 100755 debian/scripts/koha-indexer --- a/debian/docs/koha-common.xml +++ a/debian/docs/koha-common.xml @@ -145,6 +145,13 @@ Stop Zebra for named Koha instances. + + + + + Manage the indexer daemon for named Koha instances. + + --- a/debian/docs/koha-indexer.xml +++ a/debian/docs/koha-indexer.xml @@ -0,0 +1,86 @@ +
+koha-indexer + +Koha is the first free software library automation package. + + The Koha Community + http://koha-community.org/ + + + + + + + koha-indexer + 8 + + + + koha-indexer + Manage the indexer daemon for Koha instances. + UNIX/Linux + + + + + koha-indexer + |||||| + instancename + + + + Options + + + + + + + Start the indexer daemon for the desired Koha instances. + + + + + + + Stop the indexer daemon for the desired Koha instances. + + + + + + + Restart the indexer daemon for the desired Koha instances. + + + + + + + Make the script quiet about non existent instance names. Useful when calling koha-indexer from another scripts. + + + + + + + Show usage information. + + + + + + + Description + The koha-indexer script lets you manage your Koha instances indexer daemon. + + + See also + + /etc/default/koha-common + + + + + +
--- a/debian/koha-common.cron.d +++ a/debian/koha-common.cron.d @@ -6,5 +6,6 @@ SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +# Comment the following line if you want to use the experimental koha-index-daemon integration */5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled) */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl --- a/debian/koha-common.default +++ a/debian/koha-common.default @@ -0,0 +1,21 @@ +## General koha-common default options file + +PERL5LIB="/usr/share/koha/lib" + +# If you want to use the koha-index-daemon script that is part of the +# Koha::Contrib::Tamil package instead of the cronjob, set USE_INDEXER_DAEMON +# to "yes". More information can be found here: +# http://wiki.koha-community.org/wiki/PackagesIndexDaemon +# Note: You should comment the relevant line in /etc/cron.d/koha-common +# +# The default value is "no" +USE_INDEXER_DAEMON="no" + +# Indexer daemon script. The default is to use Tamil's +INDEXER_DAEMON="koha-index-daemon" + +# If you are using the koha-index-daemon you can set the frecquency (in sec) +# of the indexes update. +# +# The default value is 30 +INDEXER_TIMEOUT=30 --- a/debian/koha-common.init +++ a/debian/koha-common.init @@ -18,17 +18,14 @@ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Koha ILS" -NAME=daemonexecutablename -DAEMON=/usr/sbin/$NAME -DAEMON_ARGS="--options args" -PIDFILE=/var/run/$NAME.pid +NAME="koha-common" SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x /usr/sbin/koha-start-zebra ] || exit 0 # Read configuration variable file if it is present -# [ -r /etc/default/$NAME ] && . /etc/default/$NAME +[ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -46,6 +43,10 @@ do_start() koha-create-dirs $(koha-list) koha-start-zebra $(koha-list --enabled) koha-start-sip $(koha-list --enabled) + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --start --quiet $(koha-list --enabled) + fi } # @@ -56,6 +57,10 @@ do_stop() # We stop everything, including disabled ones. koha-stop-zebra $(koha-list) || true koha-stop-sip $(koha-list) || true + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --stop --quiet $(koha-list --enabled) + fi } # @@ -65,6 +70,10 @@ do_reload() { koha-restart-zebra $(koha-list --enabled) koha-stop-sip $(koha-list) || true koha-start-sip $(koha-list --enabled) + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --restart --quiet $(koha-list --enabled) + fi } case "$1" in @@ -84,18 +93,6 @@ case "$1" in *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; -# status) -# status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? -# ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; restart|force-reload) # # If the "reload" option is implemented then remove the @@ -118,8 +115,7 @@ case "$1" in esac ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - #echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac --- a/debian/koha-common.install +++ a/debian/koha-common.install @@ -17,6 +17,7 @@ debian/scripts/koha-email-disable usr/sbin debian/scripts/koha-email-enable usr/sbin debian/scripts/koha-enable usr/sbin debian/scripts/koha-foreach usr/sbin +debian/scripts/koha-indexer usr/sbin debian/scripts/koha-list usr/sbin debian/scripts/koha-mysql usr/sbin debian/scripts/koha-rebuild-zebra usr/sbin --- a/debian/scripts/koha-create +++ a/debian/scripts/koha-create @@ -341,6 +341,9 @@ then # Start Zebra. koha-start-zebra "$name" + + # Start Indexer daemon + koha-indexer --start "$name" fi --- a/debian/scripts/koha-indexer +++ a/debian/scripts/koha-indexer @@ -0,0 +1,277 @@ +#!/bin/bash +# +# koha-indexer - Manage Indexer Daemons for Koha instances +# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba +# +# 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 . + +set -e + +. /lib/lsb/init-functions + +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +warn() +{ + echo "$@" 1>&2 +} + +die() +{ + echo "$@" 1>&2 + exit 1 +} + +usage() +{ + local scriptname=$(basename $0) + + cat <