From tomascohen at theke.io Mon Aug 3 16:55:31 2015 From: tomascohen at theke.io (Tomas Cohen Arazi) Date: Mon, 3 Aug 2015 11:55:31 -0300 Subject: [Koha-patches] [PATCH 1/2] Bug 14639: (regression tests) Extend Koha::MetadataRecord to handle serialization format Message-ID: <1438613732-30710-1-git-send-email-tomascohen@theke.io> In order to use Koha::MetadataRecord as a container for moving records around it is important to let it carry the serialization format of the record object it was built with, so it is easier and cheaper to make decisions about records. This patch introduces regression tests for the changes to be made. The 'format' param is introduced, and also sets default values: schema => 'marc21' format => 'usmarc' so the default behaviour is preserved, and no changes are needed in places Koha::MetadataRecord is used. ->new also returns undef if no record is passed, and raises a carped warning. To test: - Apply the patch - Run the new tests $ prove t/Koha_MetadataRecord.t => FAIL: Tests shoud fail as the changes are not implemented on Koha::MetadataRecord --- t/Koha_MetadataRecord.t | 53 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/t/Koha_MetadataRecord.t b/t/Koha_MetadataRecord.t index 33cdeb1..2b2ce95 100755 --- a/t/Koha_MetadataRecord.t +++ b/t/Koha_MetadataRecord.t @@ -17,10 +17,10 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; +use Test::Warn; BEGIN { use_ok('Koha::MetadataRecord'); @@ -96,3 +96,50 @@ foreach my $field (@$hash) { is_deeply($hash, $samplehash, 'Generated hash correctly'); my $dupkeys = grep { $_ > 1 } values %fieldkeys; is($dupkeys, 0, 'No duplicate keys'); + + +subtest "new() tests" => sub { + + plan tests => 10; + + # Test default values with a MARC::Record record + my $record = MARC::Record->new(); + my $metadata_record = new Koha::MetadataRecord({ + record => $record, + schema => undef, + format => undef + }); + + is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct'); + is( ref($metadata_record->record), 'MARC::Record', 'Record type preserved'); + is( $metadata_record->schema, 'marc21', 'Metadata schema defaults to marc21'); + is( $metadata_record->format, 'usmarc', 'Serializacion format defaults to usmarc'); + + # Test passed values, also no constraint on record type + my $weird_record = {}; + bless $weird_record, 'Weird::Class'; + + $metadata_record = new Koha::MetadataRecord({ + record => $weird_record, + schema => 'something', + format => 'else' + }); + + is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct'); + is( ref($metadata_record->record), 'Weird::Class', 'Record type preserved'); + is( $metadata_record->schema, 'something', 'Metadata schema correctly set'); + is( $metadata_record->format, 'else', 'Serializacion format correctly set'); + + # Having a record object is mandatory + warning_is { $metadata_record = new Koha::MetadataRecord({ + record => undef, + schema => 'something', + format => 'else' + }) } + { carped => 'No record passed' }, + 'Undefined record raises carped warning'; + + is( $metadata_record, undef, 'record object mandatory') +}; + +1; -- 2.5.0 From tomascohen at theke.io Mon Aug 3 16:55:32 2015 From: tomascohen at theke.io (Tomas Cohen Arazi) Date: Mon, 3 Aug 2015 11:55:32 -0300 Subject: [Koha-patches] [PATCH 2/2] Bug 14639: Extend Koha::MetadataRecord to handle serialization format In-Reply-To: <1438613732-30710-1-git-send-email-tomascohen@theke.io> References: <1438613732-30710-1-git-send-email-tomascohen@theke.io> Message-ID: <1438613732-30710-2-git-send-email-tomascohen@theke.io> The description of this changes is on the regression tests commit message. To test: - Run $ prove t/Koha_MetadataRecord.t => FAIL: Tests fail because changes are not implemented - Apply this patch - Run $ prove t/Koha_MetadataRecord.t => SUCCESS: tests pass - Run $ prove t/Koha_Util_MARC.t => SUCCESS: it still passes - Sign off :-D --- Koha/MetadataRecord.pm | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/Koha/MetadataRecord.pm b/Koha/MetadataRecord.pm index 865dc0d..1a00c9d 100644 --- a/Koha/MetadataRecord.pm +++ b/Koha/MetadataRecord.pm @@ -32,15 +32,39 @@ and authority) records in Koha. =cut -use strict; -use warnings; -use C4::Context; +use Modern::Perl; + +use Carp; use Koha::Util::MARC; use base qw(Class::Accessor); -__PACKAGE__->mk_accessors(qw( record schema )); +__PACKAGE__->mk_accessors(qw( record schema format )); + + +sub new { + my $class = shift; + my $params = shift; + + if (!defined $params->{ record }) { + carp 'No record passed'; + return; + } + + my $record = $params->{ record }; + my $schema = $params->{ schema } // 'marc21'; + my $format = $params->{ format } // 'usmarc'; + + my $self = $class->SUPER::new({ + record => $record, + schema => $schema, + format => $format + }); + + bless $self, $class; + return $self; +} =head2 createMergeHash -- 2.5.0 From tomascohen at gmail.com Fri Aug 14 21:14:15 2015 From: tomascohen at gmail.com (Tomas Cohen Arazi) Date: Fri, 14 Aug 2015 16:14:15 -0300 Subject: [Koha-patches] [PATCH 1/5] Bug 13791: Plack out-of-the-box support on packages Message-ID: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> From: Tom?s Cohen Arazi This patch introduces a koha-plack script that controls running Plack processes for each instance. They are run using 'starman', listening on a Unix Domain Socket (UDS): /var/run/koha//plack.sock The plack configuration file[1] is expected to be on: /etc/koha/plack.psgi It also adds the following helper functions to koha-functions.sh: - is_plack_enabled - is_plack_running Done: - koha-plack script - suitable psgi file [1] Yeah, a single file. Because we will be relying on multiple mount points for each "app" (i.e. 'opac' and 'intranet', and 'api' ;-) ) --- debian/scripts/koha-functions.sh | 31 ++++ debian/scripts/koha-plack | 297 +++++++++++++++++++++++++++++++++++++++ debian/templates/plack.psgi | 71 ++++++++++ 3 files changed, 399 insertions(+) create mode 100755 debian/scripts/koha-plack create mode 100644 debian/templates/plack.psgi diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 8090fc5..06ca274 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -121,6 +121,37 @@ is_indexer_running() fi } +is_plack_enabled() +{ + local site=$1 + local instancefile=$(get_apache_config_for $site) + + if [ "$instancefile" = "" ]; then + return 1 + fi + + if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-opac-plack.conf' \ + "$instancefile" && \ + grep -q '^[[:space:]]*Include /etc/koha/apache-shared-intranet-plack.conf' \ + "$instancefile" ; then + return 1 + else + return 0 + fi +} + +is_plack_running() +{ + local instancename=$1 + + if start-stop-daemon --pidfile "/var/run/koha/${instancename}/plack.pid" \ + --status ; then + return 0 + else + return 1 + fi +} + get_instances() { find /etc/koha/sites -mindepth 1 -maxdepth 1\ diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack new file mode 100755 index 0000000..c481ee6 --- /dev/null +++ b/debian/scripts/koha-plack @@ -0,0 +1,297 @@ +#!/bin/bash +# +# Copyright 2015 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 < /dev/null | grep -q ${module}; then + missing_modules="${missing_modules}${module} " + fi + done + + if [ "${apache_version_ok}" != "yes" ]; then + warn "WARNING: koha-plack requires Apache 2.4.x and you don't have that." + fi + + if [ "${missing_modules}" != "" ]; then + cat 1>&2 <. + +use lib("/usr/share/koha/lib"); +use lib("/usr/share/koha/lib/installer"); + +use Plack::Builder; +use Plack::App::CGIBin; +use Plack::App::Directory; +use Plack::App::URLMap; + +#?Pre-load libraries +use C4::Boolean; +use C4::Branch; +use C4::Category; +use C4::Dates; +use C4::Koha; +use C4::Languages; +use C4::Letters; +use C4::Members; +use C4::XSLT; +use Koha::Database; + +use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise +{ + no warnings 'redefine'; + my $old_new = \&CGI::new; + *CGI::new = sub { + my $q = $old_new->( @_ ); + $CGI::PARAM_UTF8 = 1; + C4::Context->clear_syspref_cache(); + return $q; + }; +} + +my $intranet = Plack::App::CGIBin->new( + root => '/usr/share/koha/intranet/cgi-bin' +); + +my $opac = Plack::App::CGIBin->new( + root => '/usr/share/koha/opac/cgi-bin/opac' +); + +# my $api = Plack::App::CGIBin->new( +# root => '/usr/share/koha/api/' +# ); + +builder { + + enable "ReverseProxy"; + enable "Plack::Middleware::Static"; + + mount '/opac' => $opac; + mount '/intranet' => $intranet; + # mount '/api' => $api; +}; + -- 2.5.0 From tomascohen at gmail.com Fri Aug 14 21:14:16 2015 From: tomascohen at gmail.com (Tomas Cohen Arazi) Date: Fri, 14 Aug 2015 16:14:16 -0300 Subject: [Koha-patches] [PATCH 2/5] Bug 13791: Apache configuration files In-Reply-To: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> References: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> Message-ID: <1439579659-9419-2-git-send-email-tomascohen@unc.edu.ar> From: Tomas Cohen Arazi This patch adds an include to each VirtualHost definition (OPAC and Intranet) and a variable definition, taking advantage of Apache 2.4.x features. The instance name is reused inside the includes providing a simple way of dealing with the apache <-> plack configuration. A check for the right apache version is introduced, in the for of an IfVersion block: = 2.4> --- Plack configuration here --- --- debian/templates/apache-shared-intranet-plack.conf | 25 ++++++++++++++++++++++ debian/templates/apache-shared-opac-plack.conf | 25 ++++++++++++++++++++++ debian/templates/apache-site.conf.in | 8 +++++++ 3 files changed, 58 insertions(+) create mode 100644 debian/templates/apache-shared-intranet-plack.conf create mode 100644 debian/templates/apache-shared-opac-plack.conf diff --git a/debian/templates/apache-shared-intranet-plack.conf b/debian/templates/apache-shared-intranet-plack.conf new file mode 100644 index 0000000..d591a00 --- /dev/null +++ b/debian/templates/apache-shared-intranet-plack.conf @@ -0,0 +1,25 @@ +# Apache configuration settings that are shared for every Koha instance. +# This file contains settings for the Plack configuration of the intranet. +# +# This file should be included from an instance's +# /etc/apache2/site-available file, from within the VirtualHost section +# for the intranet. + +#?Plack is only available out-of-the-box for Apache 2.4.7+ setups += 2.4> + + + ProxyPreserveHost On + + # RequestHeader set X-FORWARDED-PROTO "https" + + #?Point the intranet site to Plack + ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/intranet" + ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/intranet" + + #?Point the /api endpoint to Plack + # ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock|http://localhost/api" + # ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock|http://localhost/api" + + + diff --git a/debian/templates/apache-shared-opac-plack.conf b/debian/templates/apache-shared-opac-plack.conf new file mode 100644 index 0000000..80e69ac --- /dev/null +++ b/debian/templates/apache-shared-opac-plack.conf @@ -0,0 +1,25 @@ +# Apache configuration settings that are shared for every Koha instance. +# This file contains settings for the Plack configuration of the OPAC. +# +# This file should be included from an instance's +# /etc/apache2/site-available file, from within the VirtualHost section +# for the OPAC. + +#?Plack is only available out-of-the-box for Apache 2.4.7+ setups += 2.4> + + + ProxyPreserveHost On + + # RequestHeader set X-FORWARDED-PROTO "https" + + #?Point the intranet site to Plack + ProxyPass /cgi-bin/koha/opac "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac" + ProxyPassReverse /cgi-bin/koha/opac "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac" + + #?Point the /api endpoint to Plack + # ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock|http://localhost/api" + # ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock|http://localhost/api" + + + diff --git a/debian/templates/apache-site.conf.in b/debian/templates/apache-site.conf.in index dd30bc6..73d9201 100644 --- a/debian/templates/apache-site.conf.in +++ b/debian/templates/apache-site.conf.in @@ -2,8 +2,12 @@ # OPAC + = 2.4> + Define instance "__KOHASITE__" + Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf +# Include /etc/koha/apache-shared-opac-plack.conf Include /etc/koha/apache-shared-opac.conf ServerName __OPACSERVER__ @@ -19,8 +23,12 @@ # Intranet + = 2.4> + Define instance "__KOHASITE__" + Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf +# Include /etc/koha/apache-shared-intranet-plack.conf Include /etc/koha/apache-shared-intranet.conf ServerName __INTRASERVER__ -- 2.5.0 From tomascohen at gmail.com Fri Aug 14 21:14:17 2015 From: tomascohen at gmail.com (Tomas Cohen Arazi) Date: Fri, 14 Aug 2015 16:14:17 -0300 Subject: [Koha-patches] [PATCH 3/5] Bug 13791: koha-plack documentation In-Reply-To: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> References: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> Message-ID: <1439579659-9419-3-git-send-email-tomascohen@unc.edu.ar> From: Tomas Cohen Arazi --- debian/docs/koha-plack.xml | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 debian/docs/koha-plack.xml diff --git a/debian/docs/koha-plack.xml b/debian/docs/koha-plack.xml new file mode 100644 index 0000000..a9852cd --- /dev/null +++ b/debian/docs/koha-plack.xml @@ -0,0 +1,108 @@ +
+koha-plack + +Koha is the first free software library automation package. + + The Koha community + http://koha-community.org/ + + + + + + + koha-plack + 8 + + + + koha-plack + Manage Plack for Koha instances. + UNIX/Linux + + + + + koha-plack + + | + | + | + | + | + | + || + + instancename + + + + Options + + + + + + + Start the Plack daemon for the desired Koha instances. + + + + + + + Stop the Plack daemon for the desired Koha instances. + + + + + + + Restart the Plack daemon for the desired Koha instances. + + + + + + + Enable the use of Plack for the desired Koha instances. + + + + + + + Disable the use of Plack for the desired Koha instances. + + + + + + + Make the script quiet about non existent instance names. Useful when calling koha-plack from another scripts. + + + + + + + Show usage information. + + + + + + + Description + The koha-plack script lets you manage your Koha instances Plack daemon. + + + See also + + /etc/default/koha-common + + + + + +
-- 2.5.0 From tomascohen at gmail.com Fri Aug 14 21:14:18 2015 From: tomascohen at gmail.com (Tomas Cohen Arazi) Date: Fri, 14 Aug 2015 16:14:18 -0300 Subject: [Koha-patches] [PATCH 4/5] Bug 13791: make koha-list aware of plack In-Reply-To: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> References: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> Message-ID: <1439579659-9419-4-git-send-email-tomascohen@unc.edu.ar> From: Tomas Cohen Arazi This patch adds the --plack and --noplack option switches to koha-list for filtering instances to be listed. This is particularly important for init scripts and cronjobs. To test: - Play with koha-list --plack and koha-plack --enable/--disable and verify that koha-list returns the expected results. --- debian/scripts/koha-foreach | 5 ++++ debian/scripts/koha-functions.sh | 4 +-- debian/scripts/koha-list | 61 +++++++++++++++++++++++++++++++++------- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/debian/scripts/koha-foreach b/debian/scripts/koha-foreach index 6e4d98d..925d90b 100755 --- a/debian/scripts/koha-foreach +++ b/debian/scripts/koha-foreach @@ -25,6 +25,11 @@ do --email) listopts="$listopts --email";; --noemail) listopts="$listopts --noemail";; --enabled) listopts="$listopts --enabled";; + --disabled) listopts="$listopts --disabled";; + --sip) listopts="$listopts --sip";; + --nosip) listopts="$listopts --nosip";; + --plack) listopts="$listopts --plack";; + --noplack) listopts="$listopts --noplack";; *) break;; esac shift diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 06ca274..34c6396 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -134,9 +134,9 @@ is_plack_enabled() "$instancefile" && \ grep -q '^[[:space:]]*Include /etc/koha/apache-shared-intranet-plack.conf' \ "$instancefile" ; then - return 1 - else return 0 + else + return 1 fi } diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list index 848494b..73ce075 100755 --- a/debian/scripts/koha-list +++ b/debian/scripts/koha-list @@ -37,20 +37,23 @@ show_instances() case $show in "all") if instance_filter_email $instance $show_email && \ - instance_filter_sip $instance $show_sip; then + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then echo $instance fi ;; "enabled") if is_enabled $instance; then if instance_filter_email $instance $show_email && \ - instance_filter_sip $instance $show_sip; then + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then echo $instance fi fi ;; "disabled") if ! is_enabled $instance; then if instance_filter_email $instance $show_email && \ - instance_filter_sip $instance $show_sip; then + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then echo $instance fi fi ;; @@ -81,6 +84,28 @@ instance_filter_sip() return 1 } +instance_filter_plack() +{ + local instancename=$1 + local show_plack=$2; + + case $show_plack in + "all") + return 0 ;; + "enabled") + if is_plack_enabled $instancename; then + return 0 + fi ;; + "disabled") + if ! is_plack_enabled $instancename; then + return 0 + fi ;; + esac + + # Didn't match any criteria + return 1 +} + instance_filter_email() { local instancename=$1 @@ -125,6 +150,17 @@ set_show_email() fi } +set_show_plack() +{ + local plack_param=$1 + + if [ "$show_plack" = "all" ]; then + show_plack=$plack_param + else + die "Error: --plack and --noplack are mutually exclusive." + fi +} + set_show_sip() { local sip_param=$1 @@ -146,12 +182,14 @@ email turned on. Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-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 - --sip Only show instances that have SIP enabled - --nosip Only show instances that do not have SIP enabled + --enabled Show enabled instances + --disabled Show disabled instances + --email Show instances with email enabled + --noemail Show instances with email disabled + --sip Show instances with SIP enabled + --nosip Show instances with SIP disabled + --plack Show instances with Plack enabled + --noplack Show instances with Plack disabled --help | -h Show this help The filtering options can be combined, and you probably want to do this @@ -162,8 +200,9 @@ EOH show="all" show_email="all" show_sip="all" +show_plack="all" -args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip -o h -n $0 -- "$@") +args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack -o h -n $0 -- "$@") set -- $args while [ ! -z "$1" ] @@ -174,6 +213,8 @@ do --noemail) set_show_email "disabled" ;; --sip) set_show_sip "enabled" ;; --nosip) set_show_sip "disabled" ;; + --plack) set_show_plack "enabled" ;; + --noplack) set_show_plack "disabled" ;; --enabled) set_show "enabled" ;; --disabled) set_show "disabled" ;; *) break;; -- 2.5.0 From tomascohen at gmail.com Fri Aug 14 21:14:19 2015 From: tomascohen at gmail.com (Tomas Cohen Arazi) Date: Fri, 14 Aug 2015 16:14:19 -0300 Subject: [Koha-patches] [PATCH 5/5] Bug 13791: make koha-common init script aware of plack In-Reply-To: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> References: <1439579659-9419-1-git-send-email-tomascohen@unc.edu.ar> Message-ID: <1439579659-9419-5-git-send-email-tomascohen@unc.edu.ar> From: Tomas Cohen Arazi This patch makes the packages' koha-common script aware of plack. It does so by relying on koha-list --plack to know which instances have Plack configured, and uses the koha-plack script to manage the running daemons. --- debian/koha-common.init | 66 +++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/debian/koha-common.init b/debian/koha-common.init index 241aaa6..7b99bb6 100755 --- a/debian/koha-common.init +++ b/debian/koha-common.init @@ -40,6 +40,14 @@ fi # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +# 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 + # # Function that starts the daemon/service # @@ -49,6 +57,7 @@ do_start() koha-create-dirs $(koha-list) koha-start-zebra $(koha-list --enabled) koha-start-sip $(koha-list --enabled) + koha-plack --start --quiet $(koha-list --enabled --plack) if [ "$USE_INDEXER_DAEMON" = "yes" ]; then koha-indexer --start --quiet $(koha-list --enabled) @@ -63,6 +72,7 @@ do_stop() # We stop everything, including disabled ones. koha-stop-zebra $(koha-list) || true koha-stop-sip $(koha-list) || true + koha-plack --stop --quiet $(koha-list --enabled --plack) if [ "$USE_INDEXER_DAEMON" = "yes" ]; then koha-indexer --stop --quiet $(koha-list --enabled) @@ -76,6 +86,7 @@ do_reload() { koha-restart-zebra $(koha-list --enabled) koha-stop-sip $(koha-list) || true koha-start-sip $(koha-list --enabled) + koha-plack --restart --quiet $(koha-list --enabled --plack) if [ "$USE_INDEXER_DAEMON" = "yes" ]; then koha-indexer --restart --quiet $(koha-list --enabled) @@ -83,39 +94,6 @@ do_reload() { } # -# Function that checks zebrasrv is running for the specified instance -# -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 -} - -# -# Function that checks SIP server is running for the specified instance -# -is_sip_running() -{ - local instancename=$1 - - if daemon --name="$instancename-koha-sip" \ - --pidfiles="/var/run/koha/$instancename" \ - --user="$instancename-koha.$instancename-koha" \ - --running ; then - return 0 - else - return 1 - fi -} - -# # Function that shows the status of the zebrasrv daemon for # enabled instances # @@ -123,7 +101,7 @@ zebra_status() { for instance in $(koha-list --enabled); do - log_daemon_msg "Zebra server running for instace $instance" + log_daemon_msg "Zebra server running for instance $instance" if is_zebra_running $instance ; then log_end_msg 0 @@ -141,7 +119,7 @@ sip_status() { for instance in $(koha-list --enabled --sip); do - log_daemon_msg "SIP server running for instace $instance" + log_daemon_msg "SIP server running for instance $instance" if is_sip_running $instance ; then log_end_msg 0 @@ -151,6 +129,24 @@ sip_status() done } +# +# Function that shows the status of the Plack server daemon for +# enabled instances +# +plack_status() +{ + for instance in $(koha-list --enabled --plack); do + + log_daemon_msg "Plack server running for instance ${instance}" + + if is_plack_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" -- 2.5.0