diff --git a/debian/docs/koha-email-enable.xml b/debian/docs/koha-email-enable.xml index 0f39010bff..1aeb2f1551 100644 --- a/debian/docs/koha-email-enable.xml +++ b/debian/docs/koha-email-enable.xml @@ -17,7 +17,7 @@ koha-email-enable - Turn on the email for a Koha instance. + Turn on the email for Koha instances. UNIX/Linux @@ -28,7 +28,7 @@ Description - Turn on the email for a Koha instance. + Turn on the email for Koha instances. See also diff --git a/debian/docs/koha-list.xml b/debian/docs/koha-list.xml index c67096d0ad..b58847e3c1 100644 --- a/debian/docs/koha-list.xml +++ b/debian/docs/koha-list.xml @@ -23,12 +23,12 @@ - koha-list + koha-list | | Options - The filtering options can be combined, and you probably want to do this (except --email and --noemail, that's just silly.) + 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.) @@ -36,6 +36,12 @@ Only show instances that are enabled. + + + + Only show instances that are disabled. + + diff --git a/debian/docs/koha-rebuild-zebra.xml b/debian/docs/koha-rebuild-zebra.xml index b8ce51cac3..410be8abad 100644 --- a/debian/docs/koha-rebuild-zebra.xml +++ b/debian/docs/koha-rebuild-zebra.xml @@ -17,13 +17,13 @@ koha-rebuild-zebra - Rebuild the Zebra database for a Koha instance. + Rebuild the Zebra database for Koha instances. UNIX/Linux - koha-rebuild-zebra | | instancename + koha-rebuild-zebra | | | | | instancename @@ -41,17 +41,35 @@ Does a reindex of the whole collection. + + + + Only run the indexing process for authority records. + + + + + + Only run the indexing process for biblio records. + + + + + + Be verbose. Useful for debugging indexing problems. + + - Anything else is passed directly to rebuild_zebra. This is useful in particular for -v. + Anything else is passed directly to rebuild_zebra. Description - Rebuild the Zebra database for a Koha instance. + Rebuild the Zebra database for Koha instances. See also diff --git a/debian/scripts/koha-email-enable b/debian/scripts/koha-email-enable index da63589ea0..a130c49983 100755 --- a/debian/scripts/koha-email-enable +++ b/debian/scripts/koha-email-enable @@ -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 <&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 diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list index 1e19f1afc4..f722cf10e4 100755 --- a/debian/scripts/koha-list +++ b/debian/scripts/koha-list @@ -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 <&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 <&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 <