Merge branch 'deb_scripts_312_rc1' into 3.14-master

This commit is contained in:
Jared Camins-Esakov 2013-05-15 09:32:55 -04:00
commit 771e91fdcd
7 changed files with 449 additions and 76 deletions

View File

@ -17,7 +17,7 @@
<refnamediv>
<refname>koha-email-enable</refname>
<refpurpose>Turn on the email for a Koha instance.</refpurpose>
<refpurpose>Turn on the email for Koha instances.</refpurpose>
<refclass>UNIX/Linux</refclass>
</refnamediv>
@ -28,7 +28,7 @@
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>Turn on the email for a Koha instance.</para>
<para>Turn on the email for Koha instances.</para>
</refsect1>
<refsect1><title>See also</title>

View File

@ -23,12 +23,12 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>koha-list</command> <arg><option>--enabled</option></arg> <arg><option>--email</option></arg> <arg><option>-h</option></arg>
<command>koha-list</command> <arg><option>--enabled</option>|<option>--disabled</option></arg> <arg><option>--email</option>|<option>--noemail</option></arg> <arg><option>-h</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Options</title>
<para>The filtering options can be combined, and you probably want to do this (except --email and --noemail, that's just silly.)</para>
<para>The filtering options can be combined, and you probably want to do this (except --email and --noemail, or --enabled and --disabled, that's just silly.)</para>
<variablelist>
<varlistentry>
<term><option>--enabled</option></term>
@ -36,6 +36,12 @@
<para>Only show instances that are enabled.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--disabled</option></term>
<listitem>
<para>Only show instances that are disabled.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--email</option></term>
<listitem>

View File

@ -17,13 +17,13 @@
<refnamediv>
<refname>koha-rebuild-zebra</refname>
<refpurpose>Rebuild the Zebra database for a Koha instance.</refpurpose>
<refpurpose>Rebuild the Zebra database for Koha instances.</refpurpose>
<refclass>UNIX/Linux</refclass>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<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>
<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>
</cmdsynopsis>
</refsynopsisdiv>
@ -41,17 +41,35 @@
<para>Does a reindex of the whole collection.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-a, --authorities</option></term>
<listitem>
<para>Only run the indexing process for authority records.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-b, --biblios</option></term>
<listitem>
<para>Only run the indexing process for biblio records.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v, --verbose</option></term>
<listitem>
<para>Be verbose. Useful for debugging indexing problems.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-...</option></term>
<listitem>
<para>Anything else is passed directly to rebuild_zebra. This is useful in particular for -v.</para>
<para>Anything else is passed directly to rebuild_zebra.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1><title>Description</title>
<para>Rebuild the Zebra database for a Koha instance.</para>
<para>Rebuild the Zebra database for Koha instances.</para>
</refsect1>
<refsect1><title>See also</title>

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# koha-email-enable -- turn on the email for a Koha instance
# koha-email-enable - turn on the email for Koha instances
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
@ -18,19 +18,76 @@
set -e
if [ "$#" = 0 ]
then
echo "Enables email for a koha instance." 1>&2
echo "Usage: $0 instancename..." 1>&2
die()
{
echo "$@" 1>&2
exit 1
fi
libdir=/var/lib/koha
}
warn()
{
echo "$@" 1>&2
}
is_instance()
{
local instancename=$1
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
-type d -printf '%f\n'\
| grep -q -x $instancename ; then
return 0
else
return 1
fi
}
is_email_enabled()
{
local instancename=$1
if [ -e /var/lib/koha/$instancename/email.enabled ]; then
return 0
else
return 1
fi
}
enable_email()
{
local instancename=$1
local libdir="/var/lib/koha"
touch $libdir/$instancename/email.enabled
echo "Enabled email for instance $instancename."
}
usage()
{
local scriptname=$0
cat <<EOF
Enables the email for Koha instances.
Usage: $scriptname instancename1 instancename2...
EOF
}
# Parse command line.
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
for name in "$@"
do
if [ ! -d $libdir/$name ]
then
echo "$0: no koha instance \"$name\"" 1>&2
continue
if is_instance $name; then
if ! is_email_enabled $name; then
enable_email $name
else
warn "Email already enabled for instance $name."
fi
else
warn "Unknown instance $name."
fi
touch $libdir/$name/email.enabled
done
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# koha-instances -- List all Koha instances.
# koha-list -- List all Koha instances.
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
@ -19,9 +19,18 @@
set -e
is_enabled() {
die()
{
echo "$@" 1>&2
exit 1
}
is_enabled()
{
local instancename=$1
if grep '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
"/etc/apache2/sites-available/$name" > /dev/null
"/etc/apache2/sites-available/$instancename" > /dev/null
then
return 1
else
@ -29,46 +38,125 @@ is_enabled() {
fi
}
help() {
is_email_enabled()
{
local instancename=$1
if [ -e /var/lib/koha/$instancename/email.enabled ]; then
return 0
else
return 1
fi
}
get_instances()
{
find /etc/koha/sites -mindepth 1 -maxdepth 1\
-type d -printf '%f\n' | sort
}
show_instances()
{
local show=$1
local show_email=$2
for instance in $( get_instances ); do
case $show in
"all")
show_instance_filter_email $instance $show_email;;
"enabled")
if is_enabled $instance; then
show_instance_filter_email $instance $show_email
fi ;;
"disabled")
if ! is_enabled $instance; then
show_instance_filter_email $instance $show_email
fi ;;
esac
done
}
show_instance_filter_email()
{
local instancename=$1
local show_email=$2;
case $show_email in
"all")
echo $instancename ;;
"enabled")
if is_email_enabled $instancename; then
echo $instancename
fi ;;
"disabled")
if ! is_email_enabled $instancename; then
echo $instancename
fi ;;
esac
}
set_show()
{
local show_param=$1
if [ "$show" = "all" ]; then
show=$show_param
else
die "Error: --enabled and --disabled are mutually exclusive."
fi
}
set_show_email()
{
local email_param=$1
if [ "$show_email" = "all" ]; then
show_email=$email_param
else
die "Error: --email and --noemail are mutually exclusive."
fi
}
usage()
{
local scriptname=$0
echo <<eoh
Lists Koha instances, optionally only those that are enabled or have
email turned on.
Usage: $0 [--enabled] [--email] [-h]
Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [-h]
Options:
--enabled only show instances that are enabled
--disabled only show instances that are disabled
--email only show instances that have email enabled
--noemail only show instances that do not have email enabled
-h this help
The filtering options can be combined, and you probably want to do this
(except --email and --noemail, that's just silly.)
(except --email and --noemail, or --enabled and --disabled, that's just silly.)
eoh
}
enabled=no
email=no
noemail=no
args=$(getopt -l enabled,email,noemail -o h -n $0 -- "$@")
show="all"
show_email="all"
args=$(getopt -l enabled,disabled,email,noemail -o h -n $0 -- "$@")
set -- $args
while [ ! -z "$1" ]
do
case "$1" in
-h) help; exit;;
--email) email=yes;;
--enabled) enabled=yes;;
--noemail) noemail=yes;;
-h) usage; exit;;
--email) set_show_email "enabled" ;;
--noemail) set_show_email "disabled" ;;
--enabled) set_show "enabled" ;;
--disabled) set_show "disabled" ;;
*) break;;
esac
shift
done
find /etc/koha/sites -mindepth 1 -maxdepth 1 -type d -printf '%f\n' |
sort |
while read name
do
[ "$enabled" = yes ] && ! is_enabled "$name" && continue
[ "$email" = yes ] && [ ! -e /var/lib/koha/$name/email.enabled ] && continue
[ "$noemail" = yes ] && [ -e /var/lib/koha/$name/email.enabled ] && continue
echo "$name"
done
show_instances $show $show_email
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# koha-rebuild-zebra -- Rebuild the Zebra database for a Koha instance.
# koha-rebuild-zebra - Rebuild the Zebra database for Koha instances.
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
@ -19,18 +19,117 @@
set -e
die()
{
echo "$@" 1>&2
exit 1
}
warn()
{
echo "$@" 1>&2
}
is_instance()
{
local instancename=$1
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
-type d -printf '%f\n'\
| grep -q -x $instancename ; then
return 0
else
return 1
fi
}
toggle_biblios_only()
{
biblios_only="yes"
biblios="yes"
if [ "$authorities_only" != "yes" ]; then
authorities="no"
fi
}
toggle_authorities_only()
{
authorities_only="yes"
authorities="yes"
if [ "$biblios_only" != "yes" ]; then
biblios="no"
fi
}
run_rebuild_zebra()
{
local instancename=$1; shift
# TODO: This comment is here to remind us that we should make
# rebuild_zebra.pl return error codes on failure
if sudo -u "$instancename-koha" -H \
env PERL5LIB=/usr/share/koha/lib \
KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \
/usr/share/koha/bin/migration_tools/rebuild_zebra.pl $@ ; then
return 0
else
return 1
fi
}
usage()
{
local scriptname=$0
cat <<EOF
Rebuild the Zebra indexes for Koha instances. The default behaviour
is to do an incremental rebuild.
Usage: $scriptname [options] instancename1 instancename2...
Options:
--usmarc|-u Runs the process as USMARC rather than
the default of MARCXML.
--authorities|-a Only run process for authorities.
--biblios|-b Only run process for biblios.
--full|-f Does a reindex of the whole collection.
--verbose|-v Be verbose.
--help|-h Print this help.
Note: Any other options are passed directly to rebuild_zebra.pl.
EOF
}
# Default parameters
opt_idx="-z"
opt_xml="-x"
opt_verbose=""
opts_other=""
biblios_only="no"
authorities_only="no"
biblios="yes"
authorities="yes"
# Read parameters
while [ -n "$*" ]; do
case "$1" in
-h|--help)
usage ; exit 0
;;
-b|--biblios)
toggle_biblios_only
;;
-a|--authorities)
toggle_authorities_only
;;
-u|--usmarc)
opt_xml=""
;;
opt_xml=""
;;
-f|--full)
opt_idx="-r"
;;
opt_idx="-r"
;;
-v|--verbose)
opt_verbose="-v"
;;
-*)
opts_other="$opts_other $1";
;;
@ -42,20 +141,28 @@ while [ -n "$*" ]; do
shift
done
# Parse command line.
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
run_zebra()
{
name=$1; shift
sudo -u "$name-koha" -H \
env PERL5LIB=/usr/share/koha/lib \
KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \
/usr/share/koha/bin/migration_tools/rebuild_zebra.pl $@
}
# Loop over instance names
for name in "$@"
do
run_zebra $name -b $opt_idx $opt_xml $opts_other
run_zebra $name -a $opt_idx $opts_other
if is_instance $name; then
if [ "$biblios" = "yes" ]; then
if ! run_rebuild_zebra $name \
-b $opt_verbose $opt_idx $opt_xml $opts_other; then
warn "Something went wrong rebuilding biblio indexes for $name"
fi
fi
if [ "$authorities" = "yes" ]; then
if ! run_rebuild_zebra $name \
-a $opt_verbose $opt_idx $opts_other ; then
warn "Something went wrong rebuilding authority indexes for $name"
fi
fi
else
warn "Unknown instance $name."
fi
done
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# koha-stop-zebra -- Stop Zebra for named Koha instandes
# koha-stop-zebra - Stop Zebra for named Koha instances
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
@ -18,20 +18,117 @@
set -e
die()
{
echo "$@" 1>&2
exit 1
}
warn()
{
echo "$@" 1>&2
}
is_enabled()
{
local instancename=$1
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
"/etc/apache2/sites-available/$instancename" ; then
return 1
else
return 0
fi
}
is_instance()
{
local instancename=$1
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
-type d -printf '%f\n'\
| grep -q -x $instancename ; then
return 0
else
return 1
fi
}
is_zebra_running()
{
local instancename=$1
if daemon --name="$instancename-koha-zebra" \
--user="$instancename-koha.$instancename-koha" \
--running ; then
return 0
else
return 1
fi
}
stop_zebra_instance()
{
local instancename=$1
if is_zebra_running $instancename; then
echo "Stopping Zebra server for $instancename"
daemon \
--name="$instancename-koha-zebra" \
--errlog="/var/log/koha/$instancename/zebra-error.log" \
--stdout="/var/log/koha/$instancename/zebra.log" \
--output="/var/log/koha/$instancename/zebra-output.log" \
--verbose=1 \
--respawn \
--delay=30 \
--user="$instancename-koha.$instancename-koha" \
--stop \
-- \
zebrasrv \
-v none,fatal,warn \
-f "/etc/koha/sites/$instancename/koha-conf.xml" && \
return 0
else
return 1
fi
}
usage()
{
local scriptname=$0
cat <<EOF
Stops Zebra for Koha instances.
Usage: $scriptname instancename1 instancename2...
EOF
}
# Parse command line.
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
# Loop through the instance names
for name in "$@"
do
echo "Stopping Zebra server for $name"
daemon \
--name="$name-koha-zebra" \
--errlog="/var/log/koha/$name/zebra-error.log" \
--stdout="/var/log/koha/$name/zebra.log" \
--output="/var/log/koha/$name/zebra-output.log" \
--verbose=1 \
--respawn \
--delay=30 \
--user="$name-koha.$name-koha" \
--stop \
-- \
zebrasrv \
-f "/etc/koha/sites/$name/koha-conf.xml" || true
if is_instance $name ; then
if is_enabled $name ; then
if is_zebra_running $name; then
if ! stop_zebra_instance $name; then
warn "Something went wrong stopping Zebra for $name."
fi
else
warn "Zebra already stopped for instance $name."
fi
else
warn "Instance $name disabled. No action taken."
fi
else
warn "Unknown instance $name."
fi
done
exit 0