From 6040ac6ddf356202b3c5a9580322cc5acae84813 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 13 Aug 2015 14:49:01 -0300 Subject: [PATCH] Bug 13791: make koha-list aware of plack 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-list | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list index 848494b..8286fc5 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 @@ -162,6 +198,7 @@ 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 -- "$@") set -- $args @@ -174,6 +211,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