3 # koha-indexer - Manage Indexer Daemons for Koha instances
4 # Copyright 2014 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 .
/lib
/lsb
/init-functions
23 # Read configuration variable file if it is present
24 [ -r /etc
/default
/koha-common
] && .
/etc
/default
/koha-common
26 # include helper functions
27 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
28 .
"/usr/share/koha/bin/koha-functions.sh"
30 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
36 local scriptname
=$
(basename $0)
41 This script lets you manage the indexer daemon for your Koha instances.
44 $scriptname [--start|--stop|--restart] [--quiet|-q] instancename1 [instancename2...]
47 --start Start the indexer daemon for the specified instances
48 --stop Stop the indexer daemon for the specified instances
49 --restart Restart the indexer daemon for the specified instances
50 --status Show the status of the indexer for the specified instances
51 --quiet|-q Make the script quiet about non existent instance names
52 (useful for calling from another scripts).
53 --help|-h Display this help message
62 if ! is_indexer_running
$name; then
63 export KOHA_CONF
="/etc/koha/sites/$name/koha-conf.xml"
65 DAEMONOPTS
="--name=$name-koha-indexer \
66 --errlog=/var/log/koha/$name/indexer-error.log \
67 --stdout=/var/log/koha/$name/indexer.log \
68 --output=/var/log/koha/$name/indexer-output.log \
69 --pidfiles=/var/run/koha/$name/ \
70 --verbose=1 --respawn --delay=30 \
71 --user=$name-koha.$name-koha"
73 log_daemon_msg
"Starting Koha indexing daemon for $name"
75 if daemon
$DAEMONOPTS -- $INDEXER_DAEMON $INDEXER_PARAMS; then
81 log_daemon_msg
"Error: Indexer already running for $name"
90 if is_indexer_running
$name; then
91 export KOHA_CONF
="/etc/koha/sites/$name/koha-conf.xml"
93 DAEMONOPTS
="--name=$name-koha-indexer \
94 --errlog=/var/log/koha/$name/indexer-error.log \
95 --stdout=/var/log/koha/$name/indexer.log \
96 --output=/var/log/koha/$name/indexer-output.log \
97 --pidfiles=/var/run/koha/$name/ \
98 --verbose=1 --respawn --delay=30 \
99 --user=$name-koha.$name-koha"
101 log_daemon_msg
"Stopping Koha indexing daemon for $name"
103 if daemon
$DAEMONOPTS --stop -- $INDEXER_DAEMON $INDEXER_PARAMS; then
109 log_daemon_msg
"Error: Indexer not running for $name"
118 if is_indexer_running
$name; then
119 export KOHA_CONF
="/etc/koha/sites/$name/koha-conf.xml"
121 DAEMONOPTS
="--name=$name-koha-indexer \
122 --errlog=/var/log/koha/$name/indexer-error.log \
123 --stdout=/var/log/koha/$name/indexer.log \
124 --output=/var/log/koha/$name/indexer-output.log \
125 --pidfiles=/var/run/koha/$name/ \
126 --verbose=1 --respawn --delay=30 \
127 --user=$name-koha.$name-koha"
129 log_daemon_msg
"Restarting Koha indexing daemon for $name"
131 if daemon
$DAEMONOPTS --restart -- $INDEXER_DAEMON $INDEXER_PARAMS; then
137 log_daemon_msg
"Error: Indexer not running for $name"
146 if is_indexer_running
${name}; then
147 log_daemon_msg
"Indexer running for ${name}"
150 log_daemon_msg
"Indexer not running for ${name}"
157 if [ "$op" = "" ]; then
160 die
"Error: only one action can be specified."
167 # Read command line parameters
168 while [ $# -gt 0 ]; do
192 die
"Error: invalid option switch ($1)" ;;
194 # We expect the remaining stuff are the instance names
200 # Optionally use alternative paths for a dev install
201 adjust_paths_dev_install
$1
203 # Check if an alternate indexer has been set
204 if [ ! -z $ALTERNATE_INDEXER_DAEMON ]; then
205 INDEXER_DAEMON
="$ALTERNATE_INDEXER_DAEMON"
207 # We default to rebuild_zebra.pl if no alternate indexer set
208 if [ "$DEV_INSTALL" = "" ]; then
209 INDEXER_DAEMON
="${KOHA_HOME}/bin/migration_tools/rebuild_zebra.pl"
211 INDEXER_DAEMON
="${KOHA_HOME}/misc/migration_tools/rebuild_zebra.pl"
215 if [ $INDEXER_TIMEOUT -lt 1 ]; then
216 # Something's wrong, default to 5 seconds
220 if [ -z $INDEXER_PARAMS ]; then
221 # Default to the parameters required by rebuild_zebra.pl
222 INDEXER_PARAMS
="-daemon -sleep $INDEXER_TIMEOUT $DEBUG"
225 # PERL5LIB has been read from etc/default
228 if [ $# -gt 0 ]; then
229 # We have at least one instance name
232 if is_instance
$name; then
242 restart_indexer
$name
249 if [ "$quiet" = "no" ]; then
250 log_daemon_msg
"Error: Invalid instance name $name"
257 if [ "$quiet" = "no" ]; then
258 warn
"Error: you must provide at least one instance name"