Bugzilla – Attachment 48859 Details for
Bug 16016
Integrate sitemap.pl into the packages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16016: Sitemap handling scripts for packages
Bug-16016-Sitemap-handling-scripts-for-packages.patch (text/plain), 10.69 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-03-09 13:35:10 UTC
(
hide
)
Description:
Bug 16016: Sitemap handling scripts for packages
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-03-09 13:35:10 UTC
Size:
10.69 KB
patch
obsolete
>From 5b8bddc8fde8e78a7b940e3c3124a77c4b86d787 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 8 Mar 2016 14:48:17 -0300 >Subject: [PATCH] Bug 16016: Sitemap handling scripts for packages > >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). > >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 >--- > debian/docs/koha-sitemap.xml | 92 +++++++++++++++++ > debian/scripts/koha-functions.sh | 11 +++ > debian/scripts/koha-sitemap | 208 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 311 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 0000000..4f7acbc >--- /dev/null >+++ b/debian/docs/koha-sitemap.xml >@@ -0,0 +1,92 @@ >+<article xmlns='http://docbook.org/ns/docbook'> >+<title>koha-sitemap</title> >+<info> >+<productname>Koha</productname> is the first free software library automation package. >+<author> >+ <orgname>The Koha community</orgname> >+ <uri>http://koha-community.org/</uri> >+</author> >+</info> >+ >+<refentry xml:id="koha-sitemap"> >+ >+ <refmeta> >+ <refentrytitle>koha-sitemap</refentrytitle> >+ <manvolnum>8</manvolnum> >+ </refmeta> >+ >+ <refnamediv> >+ <refname>koha-sitemap</refname> >+ <refpurpose>Manage sitemaps for Koha instances.</refpurpose> >+ <refclass>UNIX/Linux</refclass> >+ </refnamediv> >+ >+ <refsynopsisdiv> >+ <cmdsynopsis> >+ <command>koha-sitemap</command> >+ <arg choice="req" rep="norepeat"> >+ <option>--enable</option>| >+ <option>--disable</option>| >+ <option>--generate</option>| >+ <option>--help</option>|<option>-h</option> >+ |<option>--quiet</option>|<option>-q</option> >+ </arg> >+ <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg> >+ </cmdsynopsis> >+ </refsynopsisdiv> >+ >+ <refsect1><title>Options</title> >+ >+ <variablelist> >+ >+ <varlistentry> >+ <term><option>--enable</option></term> >+ <listitem> >+ <para>Enable sitemap generation for the desired Koha instances.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--disable</option></term> >+ <listitem> >+ <para>Disable sitemap generation for the desired Koha instances.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--generate</option></term> >+ <listitem> >+ <para>Generate sitemap for the desired Koha instances.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--quiet|-q</option></term> >+ <listitem> >+ <para>Make the script quiet about non existent instance names or missing directories. Useful when calling <command>koha-sitemap</command> from another scripts.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--help|-h</option></term> >+ <listitem> >+ <para>Show usage information.</para> >+ </listitem> >+ </varlistentry> >+ >+ </variablelist> >+ </refsect1> >+ >+ <refsect1><title>Description</title> >+ <para>The <command>koha-sitemap</command> script lets you manage your Koha instances sitemaps.</para> >+ </refsect1> >+ >+ <refsect1><title>See also</title> >+ <simplelist type="inline"> >+ <member><command>/etc/default/koha-common</command></member> >+ </simplelist> >+ </refsect1> >+ >+</refentry> >+ >+</article> >diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh >index 87a84a1..18c9d0a 100755 >--- a/debian/scripts/koha-functions.sh >+++ b/debian/scripts/koha-functions.sh >@@ -95,6 +95,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 0000000..c42ab34 >--- /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 <http://www.gnu.org/licenses/>. >+ >+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 <<EOF >+$scriptname >+ >+This script lets you manage sitemaps for your Koha instances. >+ >+Usage: >+$scriptname --enable|--disable instancename1 [instancename2] >+$scriptname --generate instancename1 [instancename2] >+$scriptname -h|--help >+ >+ --enable Enable sitemap generation for the specified instances >+ --disable Disable sitemap generation for the specified instances >+ --generate (Re)generate stiemap for the specified instances >+ --quiet|-q Make the script quiet about non existent instance names >+ (useful for calling from another scripts). >+ --help|-h Display this help message >+ >+EOF >+} >+ >+enable_sitemap() >+{ >+ local instance=$1 >+ local libdir="/var/lib/koha" >+ >+ if is_sitemap_enabled $instance; then >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap already enabled for ${instance}" >+ else >+ >+ sudo -u "$instance-koha" \ >+ touch $libdir/$instance/sitemap.enabled >+ >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap enabled for ${instance}" >+ fi >+} >+ >+disable_sitemap() >+{ >+ local instance=$1 >+ local libdir="/var/lib/koha" >+ >+ if is_sitemap_enabled $instance; then >+ sudo -u "$instance-koha" \ >+ rm -f $libdir/$instance/sitemap.enabled >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap disabled for ${instance}" >+ else >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap already disabled for ${instance}" >+ fi >+} >+ >+generate_sitemap() >+{ >+ local instance=$1 >+ local sitemapdir="/var/lib/koha/$instance/sitemap" >+ >+ if ! is_sitemap_enabled $instance; then >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap not enabled for ${instance}." >+ else >+ if [ ! -d "$sitemapdir" ]; then >+ # Need to create directory >+ [ "$quiet" = "no" ] && \ >+ warn "Sitemap directory for ${instance} doesn't exist. Creating." >+ sudo -u "$instance-koha" \ >+ mkdir -p "$sitemapdir" >+ fi >+ >+ if sudo -u "$instance-koha" -H \ >+ env PERL5LIB=/usr/share/koha/lib \ >+ KOHA_CONF="/etc/koha/sites/$instance/koha-conf.xml" \ >+ /usr/share/koha/bin/cronjobs/sitemap.pl \ >+ --dir $sitemapdir ; then >+ return 0 >+ else >+ return 1 >+ fi >+ fi >+} >+ >+check_env_and_warn() >+{ >+ local apache_version_ok="no" >+ >+ if /usr/sbin/apache2ctl -v | grep -q -v "Server version: Apache/2.4"; then >+ [ "$quiet" = "no" ] && \ >+ cat 1>&2 <<EOM >+WARNING: the shipped Apache configuration requires version 2.4.x and you don't have that. >+ Sitemap files will be generated, but refer to the docs to make them publicly available. >+EOM >+ fi >+} >+ >+set_action() >+{ >+ if [ "$op" = "" ]; then >+ op=$1 >+ else >+ die "Error: only one action can be specified." >+ fi >+} >+ >+op="" >+quiet="no" >+ >+# Read command line parameters >+while [ $# -gt 0 ]; do >+ >+ case "$1" in >+ -h|--help) >+ usage ; exit 0 ;; >+ -q|--quiet) >+ quiet="yes" >+ shift ;; >+ --enable) >+ set_action "enable" >+ shift ;; >+ --disable) >+ set_action "disable" >+ shift ;; >+ --generate) >+ set_action "generate" >+ shift ;; >+ -*) >+ die "Error: invalid option switch ($1)" ;; >+ *) >+ # We expect the remaining stuff are the instance names >+ break ;; >+ esac >+ >+done >+ >+if [ $# -gt 0 ]; then >+ # We have at least one instance name >+ for name in "$@"; do >+ >+ if is_instance $name; then >+ >+ case $op in >+ "generate") >+ generate_sitemap $name >+ ;; >+ "enable") >+ enable_sitemap $name >+ ;; >+ "disable") >+ disable_sitemap $name >+ ;; >+ *) >+ usage >+ ;; >+ esac >+ >+ else >+ if [ "$quiet" = "no" ]; then >+ warn "Error: Invalid instance name $name" >+ fi >+ fi >+ >+ done >+else >+ if [ "$quiet" = "no" ]; then >+ warn "Error: you must provide at least one instance name" >+ fi >+fi >+ >+exit 0 >-- >2.7.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16016
:
48859
|
48860
|
49194
|
50498
|
50831