Koha/debian/scripts/koha-functions.sh
Tomas Cohen Arazi eed7f263d0 Bug 8773 - Start per-instance koha-index-daemon in .deb setup
Short:

Launch an indexing daemon (rebuild_zebra.pl -daemon) process for each
enabled instance. Enabling/disabling the use of the indexer is handled
by global configuration variables in /etc/default/koha-common.

Also provides command line tools to manage the running indexer daemons
for your instances.

Long:

Using an indexing daemon avoids launching a new interpreter each time
the cron triggers the indexing, and also allows sub-minute incremental
reindexing, a requirement from our librarians.[1]

Using the indexer daemon could remain "experimental" until it gets more
testing; so is disabled by default initially. To enable the use of the
indexer the user has to tweak the /etc/default/koha-common config file.
Specifically the USE_INDEXER_DAEMON variable, which is clearly explained
in the file.

Frecquency defaults to 5 sec, and can be changed by tweaking the
/etc/default/koha-common config file too.

This patch uses rebuild_zebra.pl in daemon mode, but it is crafted to
allow changing the indexing daemon and passing specific option switches
it might need.

Regards
To+

[1] This is the .deb version of http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8519

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-07-14 09:15:22 -03:00

128 lines
2.6 KiB
Bash
Executable file

#!/bin/sh
#
# koha-functions.sh -- shared library of helper functions for koha-* scripts
# Copyright 2014 - Tomas Cohen Arazi
# Universidad Nacional de Cordoba
#
# 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/>.
die()
{
echo "$@" 1>&2
exit 1
}
warn()
{
echo "$@" 1>&2
}
get_apache_config_for()
{
local site=$1
local sitefile="/etc/apache2/sites-available/$site"
if is_instance $site; then
if [ -f "$sitefile.conf" ]; then
echo "$sitefile.conf"
elif [ -f "$sitefile" ]; then
echo "$sitefile"
fi
fi
}
is_enabled()
{
local site=$1
local instancefile=$(get_apache_config_for $site)
if [ "$instancefile" = "" ]; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
"$instancefile" ; then
return 1
else
return 0
fi
}
is_instance()
{
local instancename=$1
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
-type d -printf '%f\n'\
| grep -q -x "$instancename" ; then
return 0
else
return 1
fi
}
is_email_enabled()
{
local instancename=$1
if [ -e /var/lib/koha/$instancename/email.enabled ]; then
return 0
else
return 1
fi
}
is_sip_enabled()
{
local instancename=$1
if [ -e /etc/koha/sites/$instancename/SIPconfig.xml ]; then
return 0
else
return 1
fi
}
is_zebra_running()
{
local instancename=$1
if daemon --name="$instancename-koha-zebra" \
--user="$instancename-koha.$instancename-koha" \
--running ; then
return 0
else
return 1
fi
}
is_indexer_running()
{
local instancename=$1
if daemon --name="$instancename-koha-indexer" \
--user="$instancename-koha.$instancename-koha" \
--running ; then
return 0
else
return 1
fi
}
get_instances()
{
find /etc/koha/sites -mindepth 1 -maxdepth 1\
-type d -printf '%f\n' | sort
}