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

(-)a/debian/docs/koha-sitemap.xml (+92 lines)
Line 0 Link Here
1
<article xmlns='http://docbook.org/ns/docbook'>
2
<title>koha-sitemap</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-sitemap">
12
13
  <refmeta>
14
    <refentrytitle>koha-sitemap</refentrytitle>
15
    <manvolnum>8</manvolnum>
16
  </refmeta>
17
18
  <refnamediv>
19
    <refname>koha-sitemap</refname>
20
    <refpurpose>Manage sitemaps for Koha instances.</refpurpose>
21
    <refclass>UNIX/Linux</refclass>
22
  </refnamediv>
23
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
26
      <command>koha-sitemap</command>
27
      <arg choice="req" rep="norepeat">
28
        <option>--enable</option>|
29
        <option>--disable</option>|
30
        <option>--generate</option>|
31
        <option>--help</option>|<option>-h</option>
32
        |<option>--quiet</option>|<option>-q</option>
33
      </arg>
34
      <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
35
    </cmdsynopsis>
36
  </refsynopsisdiv>
37
38
  <refsect1><title>Options</title>
39
40
  <variablelist>
41
42
    <varlistentry>
43
      <term><option>--enable</option></term>
44
      <listitem>
45
        <para>Enable sitemap generation for the desired Koha instances.</para>
46
      </listitem>
47
    </varlistentry>
48
49
    <varlistentry>
50
      <term><option>--disable</option></term>
51
      <listitem>
52
        <para>Disable sitemap generation for the desired Koha instances.</para>
53
      </listitem>
54
    </varlistentry>
55
56
    <varlistentry>
57
      <term><option>--generate</option></term>
58
      <listitem>
59
        <para>Generate sitemap for the desired Koha instances.</para>
60
      </listitem>
61
    </varlistentry>
62
63
    <varlistentry>
64
      <term><option>--quiet|-q</option></term>
65
      <listitem>
66
        <para>Make the script quiet about non existent instance names or missing directories. Useful when calling <command>koha-sitemap</command> from another scripts.</para>
67
      </listitem>
68
    </varlistentry>
69
70
    <varlistentry>
71
      <term><option>--help|-h</option></term>
72
      <listitem>
73
        <para>Show usage information.</para>
74
      </listitem>
75
    </varlistentry>
76
77
  </variablelist>
78
  </refsect1>
79
80
  <refsect1><title>Description</title>
81
    <para>The <command>koha-sitemap</command> script lets you manage your Koha instances sitemaps.</para>
82
  </refsect1>
83
84
  <refsect1><title>See also</title>
85
  <simplelist type="inline">
86
    <member><command>/etc/default/koha-common</command></member>
87
  </simplelist>
88
  </refsect1>
89
90
</refentry>
91
92
</article>
(-)a/debian/koha-common.install (+1 lines)
Lines 29-34 debian/scripts/koha-restart-zebra usr/sbin Link Here
29
debian/scripts/koha-restore                 usr/sbin
29
debian/scripts/koha-restore                 usr/sbin
30
debian/scripts/koha-run-backups             usr/sbin
30
debian/scripts/koha-run-backups             usr/sbin
31
debian/scripts/koha-shell                   usr/sbin
31
debian/scripts/koha-shell                   usr/sbin
32
debian/scripts/koha-sitemap                 usr/sbin
32
debian/scripts/koha-start-zebra             usr/sbin
33
debian/scripts/koha-start-zebra             usr/sbin
33
debian/scripts/koha-stop-zebra              usr/sbin
34
debian/scripts/koha-stop-zebra              usr/sbin
34
debian/scripts/koha-translate               usr/sbin
35
debian/scripts/koha-translate               usr/sbin
(-)a/debian/scripts/koha-functions.sh (+11 lines)
Lines 95-100 is_sip_enabled() Link Here
95
    fi
95
    fi
96
}
96
}
97
97
98
is_sitemap_enabled()
99
{
100
    local instancename=$1
101
102
    if [ -e /var/lib/koha/$instancename/sitemap.enabled ]; then
103
        return 0
104
    else
105
        return 1
106
    fi
107
}
108
98
is_zebra_running()
109
is_zebra_running()
99
{
110
{
100
    local instancename=$1
111
    local instancename=$1
(-)a/debian/scripts/koha-sitemap (+208 lines)
Line 0 Link Here
1
#!/bin/bash
2
#
3
# Copyright 2016 Theke Solutions
4
#
5
# This file is part of Koha.
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
set -e
21
22
. /lib/lsb/init-functions
23
24
# Read configuration variable file if it is present
25
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
26
27
# include helper functions
28
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
29
    . "/usr/share/koha/bin/koha-functions.sh"
30
else
31
    echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
32
    exit 1
33
fi
34
35
usage()
36
{
37
    local scriptname=$(basename $0)
38
39
    cat <<EOF
40
$scriptname
41
42
This script lets you manage sitemaps for your Koha instances.
43
44
Usage:
45
$scriptname --enable|--disable instancename1 [instancename2]
46
$scriptname --generate instancename1 [instancename2]
47
$scriptname -h|--help
48
49
    --enable              Enable sitemap generation for the specified instances
50
    --disable             Disable sitemap generation for the specified instances
51
    --generate            (Re)generate stiemap for the specified instances
52
    --quiet|-q            Make the script quiet about non existent instance names
53
                          (useful for calling from another scripts).
54
    --help|-h             Display this help message
55
56
EOF
57
}
58
59
enable_sitemap()
60
{
61
    local instance=$1
62
    local libdir="/var/lib/koha"
63
64
    if is_sitemap_enabled $instance; then
65
        [ "$quiet" = "no" ] && \
66
            warn "Sitemap already enabled for ${instance}"
67
    else
68
69
        sudo -u "$instance-koha" \
70
            touch $libdir/$instance/sitemap.enabled
71
72
        [ "$quiet" = "no" ] && \
73
            warn "Sitemap enabled for ${instance}"
74
    fi
75
}
76
77
disable_sitemap()
78
{
79
    local instance=$1
80
    local libdir="/var/lib/koha"
81
82
    if is_sitemap_enabled $instance; then
83
        sudo -u "$instance-koha" \
84
            rm -f $libdir/$instance/sitemap.enabled
85
        [ "$quiet" = "no" ] && \
86
            warn "Sitemap disabled for ${instance}"
87
    else
88
        [ "$quiet" = "no" ] && \
89
            warn "Sitemap already disabled for ${instance}"
90
    fi
91
}
92
93
generate_sitemap()
94
{
95
    local instance=$1
96
    local sitemapdir="/var/lib/koha/$instance/sitemap"
97
98
    if ! is_sitemap_enabled $instance; then
99
        [ "$quiet" = "no" ] && \
100
            warn "Sitemap not enabled for ${instance}."
101
    else
102
        if [ ! -d "$sitemapdir" ]; then
103
            # Need to create directory
104
            [ "$quiet" = "no" ] && \
105
                warn "Sitemap directory for ${instance} doesn't exist. Creating."
106
            sudo -u "$instance-koha" \
107
                mkdir -p "$sitemapdir"
108
        fi
109
110
        if sudo -u "$instance-koha" -H \
111
            env PERL5LIB=/usr/share/koha/lib \
112
            KOHA_CONF="/etc/koha/sites/$instance/koha-conf.xml" \
113
            /usr/share/koha/bin/cronjobs/sitemap.pl \
114
                --dir $sitemapdir ; then
115
            return 0
116
        else
117
            return 1
118
        fi
119
    fi
120
}
121
122
check_env_and_warn()
123
{
124
    local apache_version_ok="no"
125
126
    if /usr/sbin/apache2ctl -v | grep -q -v "Server version: Apache/2.4"; then
127
        [ "$quiet" = "no" ] && \
128
            cat 1>&2 <<EOM
129
WARNING: the shipped Apache configuration requires version 2.4.x and you don't have that.
130
         Sitemap files will be generated, but refer to the docs to make them publicly available.
131
EOM
132
    fi
133
}
134
135
set_action()
136
{
137
    if [ "$op" = "" ]; then
138
        op=$1
139
    else
140
        die "Error: only one action can be specified."
141
    fi
142
}
143
144
op=""
145
quiet="no"
146
147
# Read command line parameters
148
while [ $# -gt 0 ]; do
149
150
    case "$1" in
151
        -h|--help)
152
            usage ; exit 0 ;;
153
        -q|--quiet)
154
            quiet="yes"
155
            shift ;;
156
        --enable)
157
            set_action "enable"
158
            shift ;;
159
        --disable)
160
            set_action "disable"
161
            shift ;;
162
        --generate)
163
            set_action "generate"
164
            shift ;;
165
        -*)
166
            die "Error: invalid option switch ($1)" ;;
167
        *)
168
            # We expect the remaining stuff are the instance names
169
            break ;;
170
    esac
171
172
done
173
174
if [ $# -gt 0 ]; then
175
    # We have at least one instance name
176
    for name in "$@"; do
177
178
        if is_instance $name; then
179
180
            case $op in
181
                "generate")
182
                    generate_sitemap $name
183
                    ;;
184
                "enable")
185
                    enable_sitemap $name
186
                    ;;
187
                "disable")
188
                    disable_sitemap $name
189
                    ;;
190
                *)
191
                    usage
192
                    ;;
193
            esac
194
195
        else
196
            if [ "$quiet" = "no" ]; then
197
                warn "Error: Invalid instance name $name"
198
            fi
199
        fi
200
201
    done
202
else
203
    if [ "$quiet" = "no" ]; then
204
        warn "Error: you must provide at least one instance name"
205
    fi
206
fi
207
208
exit 0
(-)a/debian/templates/apache-shared-opac.conf (-1 / +7 lines)
Lines 17-19 RewriteRule (.+) $1?%1%2 [N,R,NE] Link Here
17
RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
17
RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
18
RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
18
RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
19
RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
19
RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
20
- 
20
21
<IfVersion >= 2.4>
22
    AliasMatch "^/sitemap(.*)" "/var/lib/koha/${instance}/sitemap/sitemap$1"
23
    <Directory "/var/lib/koha/${instance}/sitemap">
24
        Require all granted
25
    </Directory>
26
</IfVersion>

Return to bug 16016