From 4e7734ce330ce73eaa5cfbd7525ea073bb2a1acb Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 8 Mar 2016 14:48:17 -0300 Subject: [PATCH] Bug 16016: Sitemap handling scripts for packages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch introduces the koha-sitemap script. This script wraps calls to the misc/cronjobs/sitemap.pl script so it can be done easily instance-wise. It sets /var/lib/koha/${instance}/sitemap as the destination directory for the sitemap files. A followup will make them available through an Apache configuration entry. koha-functions.sh is provided with a handy is_sitemap_enabled function so we can later add filters to other commands (koha-list, koha-foreach, etc). Exposes sitemap files to apache. This is suitable for including the sitemap in the robots.txt file as proposed in http://www.sitemaps.org/protocol.html#submit_robots Note: it depends on Apache 2.4+ so we can patch the file as needed. Older Apache users will be warned that they need to tweak the apache files on their own. To test: - You can build a package out of this patchset, or do the following on a kohadevbox cp debian/scripts/koha-functions.sh /usr/share/koha/bin - Run $ debian/scripts/koha-sitemap --help - Go through all the options (--enable, --disable, generate). (a) --enable: - debian/scripts/koha-sitemap --enable kohadev => SUCCESS: /var/lib/koha/kohadev/sitemap.enabled is created - call it again, a suitable warning is raised and the file is still there (b) debian/scripts/koha-sitemap --disable kohadev => SUCCESS: /var/lib/koha/kohadev/sitemap.enabled is deleted - call it again, a suitable warning is raised and the file does not exist (c) --generate: - debian/scripts/koha-sitemap --generate kohadev => SUCCESS: sitemapindex.xml and sitemap000X.xml files are generated in /var/lib/koha/kohadev/sitemap/ - Sign off :-D Sponsored-by: Orex Digital Signed-off-by: Frédéric Demians Signed-off-by: Kyle M Hall --- debian/docs/koha-sitemap.xml | 92 ++++++++++ debian/koha-common.install | 1 + debian/scripts/koha-functions.sh | 11 ++ debian/scripts/koha-sitemap | 208 +++++++++++++++++++++++ debian/templates/apache-shared-opac.conf | 7 + 5 files changed, 319 insertions(+) create mode 100644 debian/docs/koha-sitemap.xml create mode 100755 debian/scripts/koha-sitemap diff --git a/debian/docs/koha-sitemap.xml b/debian/docs/koha-sitemap.xml new file mode 100644 index 0000000000..4f7acbcf4d --- /dev/null +++ b/debian/docs/koha-sitemap.xml @@ -0,0 +1,92 @@ +
+koha-sitemap + +Koha is the first free software library automation package. + + The Koha community + http://koha-community.org/ + + + + + + + koha-sitemap + 8 + + + + koha-sitemap + Manage sitemaps for Koha instances. + UNIX/Linux + + + + + koha-sitemap + + | + | + | + | + || + + instancename + + + + Options + + + + + + + Enable sitemap generation for the desired Koha instances. + + + + + + + Disable sitemap generation for the desired Koha instances. + + + + + + + Generate sitemap for the desired Koha instances. + + + + + + + Make the script quiet about non existent instance names or missing directories. Useful when calling koha-sitemap from another scripts. + + + + + + + Show usage information. + + + + + + + Description + The koha-sitemap script lets you manage your Koha instances sitemaps. + + + See also + + /etc/default/koha-common + + + + + +
diff --git a/debian/koha-common.install b/debian/koha-common.install index 6c2025c04d..270a54a7c9 100644 --- a/debian/koha-common.install +++ b/debian/koha-common.install @@ -29,6 +29,7 @@ debian/scripts/koha-restart-zebra usr/sbin debian/scripts/koha-restore usr/sbin debian/scripts/koha-run-backups usr/sbin debian/scripts/koha-shell usr/sbin +debian/scripts/koha-sitemap usr/sbin debian/scripts/koha-start-zebra usr/sbin debian/scripts/koha-stop-zebra usr/sbin debian/scripts/koha-translate usr/sbin diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 1c309fc4d1..cf6835d8ad 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -146,6 +146,17 @@ is_sip_enabled() fi } +is_sitemap_enabled() +{ + local instancename=$1 + + if [ -e /var/lib/koha/$instancename/sitemap.enabled ]; then + return 0 + else + return 1 + fi +} + is_zebra_running() { local instancename=$1 diff --git a/debian/scripts/koha-sitemap b/debian/scripts/koha-sitemap new file mode 100755 index 0000000000..c42ab345a6 --- /dev/null +++ b/debian/scripts/koha-sitemap @@ -0,0 +1,208 @@ +#!/bin/bash +# +# Copyright 2016 Theke Solutions +# +# This file is part of Koha. +# +# 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 . + +set -e + +. /lib/lsb/init-functions + +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + +usage() +{ + local scriptname=$(basename $0) + + cat <&2 <= 2.4> + AliasMatch "^/sitemap(.*)" "/var/lib/koha/${instance}/sitemap/sitemap$1" + + Require all granted + + -- 2.39.5