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

(-)a/debian/docs/koha-rebuild-zebra.xml (-4 / +22 lines)
Lines 17-29 Link Here
17
17
18
  <refnamediv>
18
  <refnamediv>
19
    <refname>koha-rebuild-zebra</refname>
19
    <refname>koha-rebuild-zebra</refname>
20
    <refpurpose>Rebuild the Zebra database for a Koha instance.</refpurpose>
20
    <refpurpose>Rebuild the Zebra database for Koha instances.</refpurpose>
21
    <refclass>UNIX/Linux</refclass>
21
    <refclass>UNIX/Linux</refclass>
22
  </refnamediv>
22
  </refnamediv>
23
23
24
  <refsynopsisdiv>
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
25
    <cmdsynopsis>
26
      <command>koha-rebuild-zebra</command> <arg><option>-u</option>|<option>--usmarc</option></arg> <arg><option>-f</option>|<option>--full</option></arg> <arg><option>...</option></arg> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
26
      <command>koha-rebuild-zebra</command> <arg><option>-u</option>|<option>--usmarc</option></arg> <arg><option>-f</option>|<option>--full</option></arg> <arg><option>-a</option>|<option>--authorities</option></arg> <arg><option>-b</option>|<option>--biblios</option></arg> <arg><option>-v</option>|<option>--verbose</option></arg> <arg><option>...</option></arg> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
27
    </cmdsynopsis>
27
    </cmdsynopsis>
28
  </refsynopsisdiv>
28
  </refsynopsisdiv>
29
  
29
  
Lines 42-57 Link Here
42
      </listitem>
42
      </listitem>
43
    </varlistentry>
43
    </varlistentry>
44
    <varlistentry>
44
    <varlistentry>
45
      <term><option>-a, --authorities</option></term>
46
      <listitem>
47
        <para>Only run the indexing process for authority records.</para>
48
      </listitem>
49
    </varlistentry>
50
    <varlistentry>
51
      <term><option>-b, --biblios</option></term>
52
      <listitem>
53
        <para>Only run the indexing process for biblio records.</para>
54
      </listitem>
55
    </varlistentry>
56
    <varlistentry>
57
      <term><option>-v, --verbose</option></term>
58
      <listitem>
59
        <para>Be verbose. Useful for debugging indexing problems.</para>
60
      </listitem>
61
    </varlistentry>
62
    <varlistentry>
45
      <term><option>-...</option></term>
63
      <term><option>-...</option></term>
46
      <listitem>
64
      <listitem>
47
        <para>Anything else is passed directly to rebuild_zebra. This is useful in particular for -v.</para>
65
        <para>Anything else is passed directly to rebuild_zebra.</para>
48
      </listitem>
66
      </listitem>
49
    </varlistentry>
67
    </varlistentry>
50
  </variablelist>
68
  </variablelist>
51
  </refsect1>
69
  </refsect1>
52
70
53
  <refsect1><title>Description</title>
71
  <refsect1><title>Description</title>
54
  <para>Rebuild the Zebra database for a Koha instance.</para>
72
  <para>Rebuild the Zebra database for Koha instances.</para>
55
  </refsect1>
73
  </refsect1>
56
  
74
  
57
  <refsect1><title>See also</title>
75
  <refsect1><title>See also</title>
(-)a/debian/scripts/koha-rebuild-zebra (-19 / +125 lines)
Lines 1-6 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# koha-rebuild-zebra -- Rebuild the Zebra database for a Koha instance.
3
# koha-rebuild-zebra - Rebuild the Zebra database for Koha instances.
4
# Copyright 2010  Catalyst IT, Ltd
4
# Copyright 2010  Catalyst IT, Ltd
5
# 
5
# 
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
Lines 19-36 Link Here
19
19
20
set -e
20
set -e
21
21
22
die()
23
{
24
    echo "$@" 1>&2
25
    exit 1
26
}
27
28
warn()
29
{
30
    echo "$@" 1>&2
31
}
32
33
is_instance()
34
{
35
    local instancename=$1
36
37
    if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
38
                         -type d -printf '%f\n'\
39
          | grep -q -x $instancename ; then
40
        return 0
41
    else
42
        return 1
43
    fi
44
}
45
46
toggle_biblios_only()
47
{
48
    biblios_only="yes"
49
    biblios="yes"
50
    if [ "$authorities_only" != "yes" ]; then
51
        authorities="no"
52
    fi
53
}
54
55
toggle_authorities_only()
56
{
57
    authorities_only="yes"
58
    authorities="yes"
59
    if [ "$biblios_only" != "yes" ]; then
60
        biblios="no"
61
    fi
62
}
63
64
run_rebuild_zebra()
65
{
66
    local instancename=$1; shift
67
68
    # TODO: This comment is here to remind us that we should make
69
    # rebuild_zebra.pl return error codes on failure
70
    if sudo -u "$instancename-koha" -H \
71
        env PERL5LIB=/usr/share/koha/lib \
72
        KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \
73
        /usr/share/koha/bin/migration_tools/rebuild_zebra.pl $@ ; then
74
        return 0
75
    else
76
        return 1
77
    fi
78
}
79
80
usage()
81
{
82
    local scriptname=$0
83
    cat <<EOF
84
Rebuild the Zebra indexes for Koha instances. The default behaviour
85
is to do an incremental rebuild.
86
87
Usage: $scriptname [options] instancename1 instancename2...
88
Options:
89
    --usmarc|-u       Runs the process as USMARC rather than
90
                      the default of MARCXML.
91
    --authorities|-a  Only run process for authorities.
92
    --biblios|-b      Only run process for biblios.
93
    --full|-f         Does a reindex of the whole collection.
94
    --verbose|-v      Be verbose.
95
    --help|-h         Print this help.
96
97
98
Note: Any other options are passed directly to rebuild_zebra.pl.
99
EOF
100
}
101
102
# Default parameters
22
opt_idx="-z"
103
opt_idx="-z"
23
opt_xml="-x"
104
opt_xml="-x"
105
opt_verbose=""
24
opts_other=""
106
opts_other=""
107
biblios_only="no"
108
authorities_only="no"
109
biblios="yes"
110
authorities="yes"
25
111
112
# Read parameters
26
while [ -n "$*" ]; do
113
while [ -n "$*" ]; do
27
    case "$1" in
114
    case "$1" in
115
        -h|--help)
116
            usage ; exit 0
117
            ;;
118
        -b|--biblios)
119
            toggle_biblios_only
120
            ;;
121
        -a|--authorities)
122
            toggle_authorities_only
123
            ;;
28
        -u|--usmarc)
124
        -u|--usmarc)
29
             opt_xml=""
125
            opt_xml=""
30
             ;;
126
            ;;
31
        -f|--full)
127
        -f|--full)
32
             opt_idx="-r"
128
            opt_idx="-r"
33
             ;;
129
            ;;
130
        -v|--verbose)
131
            opt_verbose="-v"
132
            ;;
34
        -*)
133
        -*)
35
            opts_other="$opts_other $1";
134
            opts_other="$opts_other $1";
36
            ;;
135
            ;;
Lines 42-61 while [ -n "$*" ]; do Link Here
42
    shift
141
    shift
43
done
142
done
44
143
144
# Parse command line.
145
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
45
146
46
147
# Loop over instance names
47
run_zebra() 
48
{
49
    name=$1; shift
50
51
    sudo -u "$name-koha" -H \
52
    env PERL5LIB=/usr/share/koha/lib \
53
        KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \
54
        /usr/share/koha/bin/migration_tools/rebuild_zebra.pl $@
55
}
56
57
for name in "$@"
148
for name in "$@"
58
do
149
do
59
    run_zebra $name -b $opt_idx $opt_xml $opts_other
150
    if is_instance $name; then
60
    run_zebra $name -a $opt_idx $opts_other
151
        if [ "$biblios" = "yes" ]; then
152
            if ! run_rebuild_zebra $name \
153
                -b $opt_verbose $opt_idx $opt_xml $opts_other; then
154
                warn "Something went wrong rebuilding biblio indexes for $name"
155
            fi
156
        fi
157
        if [ "$authorities" = "yes" ]; then
158
            if ! run_rebuild_zebra $name \
159
                -a $opt_verbose $opt_idx $opts_other ; then
160
                warn "Something went wrong rebuilding authority indexes for $name"
161
            fi
162
        fi
163
    else
164
        warn "Unknown instance $name."
165
    fi
61
done
166
done
62
- 
167
168
exit 0

Return to bug 10159