View | Details | Raw Unified | Return to bug 8773
Collapse All | Expand All

(-)a/debian/docs/koha-common.xml (+7 lines)
Lines 145-150 Link Here
145
          <para>Stop Zebra for named Koha instances.</para>
145
          <para>Stop Zebra for named Koha instances.</para>
146
        </listitem>
146
        </listitem>
147
      </varlistentry>
147
      </varlistentry>
148
149
      <varlistentry>
150
        <term><option>koha-indexer</option></term>
151
        <listitem>
152
          <para>Manage the indexer daemon for named Koha instances.</para>
153
        </listitem>
154
      </varlistentry>
148
    </variablelist>
155
    </variablelist>
149
    </refsect2>
156
    </refsect2>
150
157
(-)a/debian/docs/koha-indexer.xml (+86 lines)
Line 0 Link Here
1
<article xmlns='http://docbook.org/ns/docbook'>
2
<title>koha-indexer</title>
3
<info>
4
<productname>Koha</productname> is the first free software library automation package.
5
<author>
6
  <orgname>The Koha Community</orgname>
7
  <uri>http://koha-community.org/</uri>
8
</author>
9
</info>
10
11
<refentry xml:id="koha-indexer">
12
13
  <refmeta>
14
    <refentrytitle>koha-indexer</refentrytitle>
15
    <manvolnum>8</manvolnum>
16
  </refmeta>
17
18
  <refnamediv>
19
    <refname>koha-indexer</refname>
20
    <refpurpose>Manage the indexer daemon for Koha instances.</refpurpose>
21
    <refclass>UNIX/Linux</refclass>
22
  </refnamediv>
23
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
26
      <command>koha-indexer</command>
27
      <arg choice="req"><option>--start</option>|<option>--stop</option>|<option>--restart</option>|<option>--help</option>|<option>-h</option>|<option>--quiet</option>|<option>-q</option></arg>
28
      <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
29
    </cmdsynopsis>
30
  </refsynopsisdiv>
31
32
  <refsect1><title>Options</title>
33
34
  <variablelist>
35
36
    <varlistentry>
37
      <term><option>--start</option></term>
38
      <listitem>
39
        <para>Start the indexer daemon for the desired Koha instances.</para>
40
      </listitem>
41
    </varlistentry>
42
43
    <varlistentry>
44
      <term><option>--stop</option></term>
45
      <listitem>
46
        <para>Stop the indexer daemon for the desired Koha instances.</para>
47
      </listitem>
48
    </varlistentry>
49
50
    <varlistentry>
51
      <term><option>--restart</option></term>
52
      <listitem>
53
        <para>Restart the indexer daemon for the desired Koha instances.</para>
54
      </listitem>
55
    </varlistentry>
56
57
    <varlistentry>
58
      <term><option>--quiet|-q</option></term>
59
      <listitem>
60
        <para>Make the script quiet about non existent instance names. Useful when calling <command>koha-indexer</command> from another scripts.</para>
61
      </listitem>
62
    </varlistentry>
63
64
    <varlistentry>
65
      <term><option>--help|-h</option></term>
66
      <listitem>
67
        <para>Show usage information.</para>
68
      </listitem>
69
    </varlistentry>
70
71
  </variablelist>
72
  </refsect1>
73
74
  <refsect1><title>Description</title>
75
    <para>The <command>koha-indexer</command> script lets you manage your Koha instances indexer daemon.</para>
76
  </refsect1>
77
78
  <refsect1><title>See also</title>
79
  <simplelist type="inline">
80
    <member><command>/etc/default/koha-common</command></member>
81
  </simplelist>
82
  </refsect1>
83
84
</refentry>
85
86
</article>
(-)a/debian/koha-common.cron.d (+1 lines)
Lines 6-10 Link Here
6
SHELL=/bin/sh
6
SHELL=/bin/sh
7
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
7
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
8
8
9
# Comment the following line if you want to use the experimental koha-index-daemon integration
9
*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled)
10
*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled)
10
*/15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl
11
*/15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl
(-)a/debian/koha-common.default (-1 / +19 lines)
Lines 1-3 Link Here
1
## General koha-common default options
1
## General koha-common default options file
2
2
3
PERL5LIB="/usr/share/koha/lib"
3
PERL5LIB="/usr/share/koha/lib"
4
5
# If you want to use the koha-index-daemon script that is part of the
6
# Koha::Contrib::Tamil package instead of the cronjob, set USE_INDEXER_DAEMON
7
# to "yes". More information can be found here:
8
#     http://wiki.koha-community.org/wiki/PackagesIndexDaemon
9
# Note: You should comment the relevant line in /etc/cron.d/koha-common
10
#
11
# The default value is "no"
12
USE_INDEXER_DAEMON="no"
13
14
# Indexer daemon script. The default is to use Tamil's
15
INDEXER_DAEMON="koha-index-daemon"
16
17
# If you are using the koha-index-daemon you can set the frecquency (in sec)
18
# of the indexes update.
19
#
20
# The default value is 30
21
INDEXER_TIMEOUT=30
(-)a/debian/koha-common.init (+12 lines)
Lines 49-54 do_start() Link Here
49
    koha-create-dirs $(koha-list)
49
    koha-create-dirs $(koha-list)
50
    koha-start-zebra $(koha-list --enabled)
50
    koha-start-zebra $(koha-list --enabled)
51
    koha-start-sip $(koha-list --enabled)
51
    koha-start-sip $(koha-list --enabled)
52
53
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
54
        koha-indexer --start --quiet $(koha-list --enabled)
55
    fi
52
}
56
}
53
57
54
#
58
#
Lines 59-64 do_stop() Link Here
59
    # We stop everything, including disabled ones.
63
    # We stop everything, including disabled ones.
60
    koha-stop-zebra $(koha-list) || true
64
    koha-stop-zebra $(koha-list) || true
61
    koha-stop-sip $(koha-list) || true
65
    koha-stop-sip $(koha-list) || true
66
67
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
68
        koha-indexer --stop --quiet $(koha-list --enabled)
69
    fi
62
}
70
}
63
71
64
#
72
#
Lines 68-73 do_reload() { Link Here
68
    koha-restart-zebra $(koha-list --enabled)
76
    koha-restart-zebra $(koha-list --enabled)
69
    koha-stop-sip $(koha-list) || true
77
    koha-stop-sip $(koha-list) || true
70
    koha-start-sip $(koha-list --enabled)
78
    koha-start-sip $(koha-list --enabled)
79
80
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
81
        koha-indexer --restart --quiet $(koha-list --enabled)
82
    fi
71
}
83
}
72
84
73
#
85
#
(-)a/debian/koha-common.install (+1 lines)
Lines 16-21 debian/scripts/koha-email-disable usr/sbin Link Here
16
debian/scripts/koha-email-enable            usr/sbin
16
debian/scripts/koha-email-enable            usr/sbin
17
debian/scripts/koha-enable                  usr/sbin
17
debian/scripts/koha-enable                  usr/sbin
18
debian/scripts/koha-foreach                 usr/sbin
18
debian/scripts/koha-foreach                 usr/sbin
19
debian/scripts/koha-indexer                 usr/sbin
19
debian/scripts/koha-list                    usr/sbin
20
debian/scripts/koha-list                    usr/sbin
20
debian/scripts/koha-mysql                   usr/sbin
21
debian/scripts/koha-mysql                   usr/sbin
21
debian/scripts/koha-rebuild-zebra           usr/sbin
22
debian/scripts/koha-rebuild-zebra           usr/sbin
(-)a/debian/scripts/koha-create (+7 lines)
Lines 16-21 Link Here
16
# You should have received a copy of the GNU General Public License
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/>.
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
19
# Read configuration variable file if it is present
20
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
19
21
20
set -e
22
set -e
21
23
Lines 450-455 then Link Here
450
452
451
    # Start Zebra.
453
    # Start Zebra.
452
    koha-start-zebra "$name"
454
    koha-start-zebra "$name"
455
456
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
457
        # Start Indexer daemon
458
        koha-indexer --start "$name"
459
    fi
453
fi
460
fi
454
461
455
462
(-)a/debian/scripts/koha-indexer (-1 / +277 lines)
Line 0 Link Here
0
- 
1
#!/bin/bash
2
#
3
# koha-indexer - Manage Indexer Daemons for Koha instances
4
# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
5
#
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.
10
#
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.
15
#
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/>.
18
19
set -e
20
21
. /lib/lsb/init-functions
22
23
# Read configuration variable file if it is present
24
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
25
26
warn()
27
{
28
    echo "$@" 1>&2
29
}
30
31
die()
32
{
33
    echo "$@" 1>&2
34
    exit 1
35
}
36
37
usage()
38
{
39
    local scriptname=$(basename $0)
40
41
    cat <<EOF
42
$scriptname
43
44
This script lets you manage the indexer daemon for your Koha instances.
45
46
Usage:
47
$scriptname [--start|--stop|--restart] [--quiet|-q] instancename1 [instancename2...]
48
$scriptname -h|--help
49
50
    --start               Start the indexer daemon for the specified instances
51
    --stop                Stop the indexer daemon for the specified instances
52
    --restart             Restart the indexer daemon for the specified instances
53
    --quiet|-q            Make the script quiet about non existent instance names
54
    --help|-h             Display this help message
55
56
EOF
57
}
58
59
is_instance()
60
{
61
    local instancename=$1
62
63
    if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
64
                         -type d -printf '%f\n'\
65
          | grep -q -x -e "$instancename" ; then
66
        return 0
67
    else
68
        return 1
69
    fi
70
}
71
72
is_indexer_running()
73
{
74
    local instancename=$1
75
76
    if daemon --name="$instancename-koha-indexer" \
77
            --user="$instancename-koha.$instancename-koha" \
78
            --running ; then
79
        return 0
80
    else
81
        return 1
82
    fi
83
}
84
85
start_indexer()
86
{
87
    local name=$1
88
89
    if ! is_indexer_running $name; then
90
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
91
92
        INDEXDAEMON_OPTS="--timeout $INDEXER_TIMEOUT \
93
                        --conf $KOHA_CONF \
94
                        --directory /var/tmp/koha-indexer-daemon-$name"
95
96
        DAEMONOPTS="--name=$name-koha-indexer \
97
            --errlog=/var/log/koha/$name/indexer-error.log \
98
            --stdout=/var/log/koha/$name/indexer.log \
99
            --output=/var/log/koha/$name/indexer-output.log \
100
            --verbose=1 --respawn --delay=30 \
101
            --user=$name-koha.$name-koha"
102
103
        log_daemon_msg "Starting Koha indexing daemon for $name"
104
105
        if daemon $DAEMONOPTS -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
106
            log_end_msg 0
107
        else
108
            log_end_msg 1
109
        fi
110
    else
111
        log_daemon_msg "Error: Indexer already running for $name"
112
        log_end_msg 1
113
    fi
114
}
115
116
stop_indexer()
117
{
118
    local name=$1
119
120
    if is_indexer_running $name; then
121
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
122
123
        INDEXDAEMON_OPTS="--timeout 30 \
124
                        --conf $KOHA_CONF \
125
                        --directory /var/tmp/koha-indexer-daemon-$name"
126
127
        DAEMONOPTS="--name=$name-koha-indexer \
128
            --errlog=/var/log/koha/$name/indexer-error.log \
129
            --stdout=/var/log/koha/$name/indexer.log \
130
            --output=/var/log/koha/$name/indexer-output.log \
131
            --verbose=1 --respawn --delay=30 \
132
            --user=$name-koha.$name-koha"
133
134
        log_daemon_msg "Stopping Koha indexing daemon for $name"
135
136
        if daemon $DAEMONOPTS --stop -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
137
            log_end_msg 0
138
        else
139
            log_end_msg 1
140
        fi
141
    else
142
        log_daemon_msg "Error: Indexer not running for $name"
143
        log_end_msg 1
144
    fi
145
}
146
147
restart_indexer()
148
{
149
    local name=$1
150
151
    if is_indexer_running $name; then
152
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
153
154
        INDEXDAEMON_OPTS="--timeout 30 \
155
                        --conf $KOHA_CONF \
156
                        --directory /var/tmp/koha-indexer-daemon-$name"
157
158
        DAEMONOPTS="--name=$name-koha-indexer \
159
            --errlog=/var/log/koha/$name/indexer-error.log \
160
            --stdout=/var/log/koha/$name/indexer.log \
161
            --output=/var/log/koha/$name/indexer-output.log \
162
            --verbose=1 --respawn --delay=30 \
163
            --user=$name-koha.$name-koha"
164
165
        log_daemon_msg "Stopping Koha indexing daemon for $name"
166
167
        if daemon $DAEMONOPTS --restart -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
168
            log_end_msg 0
169
        else
170
            log_end_msg 1
171
        fi
172
    else
173
        log_daemon_msg "Error: Indexer not running for $name"
174
        log_end_msg 1
175
    fi
176
}
177
178
set_action()
179
{
180
    if [ "$op" = "" ]; then
181
        op=$1
182
    else
183
        die "Error: only one action can be specified."
184
    fi
185
}
186
187
op=""
188
quiet="no"
189
190
# Read command line parameters
191
while [ $# -gt 0 ]; do
192
193
    case "$1" in
194
        -h|--help)
195
            usage ; exit 0 ;;
196
        -q|--quiet)
197
            quiet="yes"
198
            shift ;;
199
        --start)
200
            set_action "start"
201
            shift ;;
202
        --stop)
203
            set_action "stop"
204
            shift ;;
205
        --restart)
206
            set_action "restart"
207
            shift ;;
208
        -*)
209
            die "Error: invalid option switch ($1)" ;;
210
        *)
211
            # We expect the remaining stuff are the instance names
212
            break ;;
213
    esac
214
215
done
216
217
# Some default variables
218
if [ -z $INDEXER_DAEMON ]; then
219
    INDEXER_DAEMON="koha-index-daemon"
220
fi
221
222
if [ -z $PERL5LIB ]; then
223
    PERL5LIB="/usr/share/koha/lib"
224
fi
225
226
export PERL5LIB
227
228
if [ $INDEXER_TIMEOUT -lt 1 ]; then
229
    # Something's wrong, default to 30
230
    INDEXER_TIMEOUT=30
231
fi
232
233
234
if [ ! -e /usr/share/perl5/Koha/Contrib/Tamil/IndexerDaemon.pm ] ; then
235
    MSG=`cat <<EOF
236
Koha::Contrib::Tamil::IndexerDaemon was not found. See
237
http://wiki.koha-community.org/wiki/PackagesIndexDaemon
238
for instructions on setting up the indexer daemon.
239
EOF`
240
241
    die $MSG
242
fi
243
244
245
if [ $# -gt 0 ]; then
246
    # We have at least one instance name
247
    for name in "$@"; do
248
249
        if is_instance $name; then
250
251
            case $op in
252
                "start")
253
                    start_indexer $name
254
                    ;;
255
                "stop")
256
                    stop_indexer $name
257
                    ;;
258
                "restart")
259
                    restart_indexer $name
260
                    ;;
261
            esac
262
263
        else
264
            if [ "$quiet" = "no" ]; then
265
                log_daemon_msg "Error: Invalid instance name $name"
266
                log_end_msg 1
267
            fi
268
        fi
269
270
    done
271
else
272
    if [ "$quiet" = "no" ]; then
273
        warn "Error: you must provide at least one instance name"
274
    fi
275
fi
276
277
exit 0

Return to bug 8773