Bug 33108: Teach koha-list filter elasticsearch
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
37d832da31
commit
a4b88d5568
4 changed files with 123 additions and 71 deletions
13
debian/docs/koha-list.xml
vendored
13
debian/docs/koha-list.xml
vendored
|
@ -25,6 +25,7 @@
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>koha-list</command>
|
<command>koha-list</command>
|
||||||
<arg><option>--enabled</option>|<option>--disabled</option></arg>
|
<arg><option>--enabled</option>|<option>--disabled</option></arg>
|
||||||
|
<arg><option>--elasticsearch</option>|<option>--noelasticsearch</option></arg>
|
||||||
<arg><option>--email</option>|<option>--noemail</option></arg>
|
<arg><option>--email</option>|<option>--noemail</option></arg>
|
||||||
<arg><option>--sip</option>|<option>--nosip</option></arg>
|
<arg><option>--sip</option>|<option>--nosip</option></arg>
|
||||||
<arg><option>--plack</option>|<option>--noplack</option></arg>
|
<arg><option>--plack</option>|<option>--noplack</option></arg>
|
||||||
|
@ -47,6 +48,18 @@
|
||||||
<para>Only show instances that are disabled.</para>
|
<para>Only show instances that are disabled.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--elasticsearch</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Only show instances that have elasticsearch enabled.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--noelasticsearch</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Only show instances that do not have elasticsearch enabled.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--email</option></term>
|
<term><option>--email</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
6
debian/koha-common.bash-completion
vendored
6
debian/koha-common.bash-completion
vendored
|
@ -131,7 +131,7 @@ _koha_list()
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
_get_comp_words_by_ref cur
|
_get_comp_words_by_ref cur
|
||||||
opts="--enabled --disabled --email --noemail --plack --noplack --sip --nosip --help -h"
|
opts="--enabled --disabled --email --noemail --plack --noplack --sip --nosip --help -h --elasticsearch --noelasticsearch"
|
||||||
|
|
||||||
# Build a list of the already used option switches
|
# Build a list of the already used option switches
|
||||||
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
||||||
|
@ -141,6 +141,10 @@ _koha_list()
|
||||||
substract="$substract -e --enabled"; ;;
|
substract="$substract -e --enabled"; ;;
|
||||||
--enabled)
|
--enabled)
|
||||||
substract="$substract -e --disabled"; ;;
|
substract="$substract -e --disabled"; ;;
|
||||||
|
--elasticsearch)
|
||||||
|
substract="$substract -e --noelasticsearch"; ;;
|
||||||
|
--noelasticsearch)
|
||||||
|
substract="$substract -e --elasticsearch"; ;;
|
||||||
--email)
|
--email)
|
||||||
substract="$substract -e --noemail"; ;;
|
substract="$substract -e --noemail"; ;;
|
||||||
--noemail)
|
--noemail)
|
||||||
|
|
6
debian/koha-core.bash-completion
vendored
6
debian/koha-core.bash-completion
vendored
|
@ -131,7 +131,7 @@ _koha_list()
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
_get_comp_words_by_ref cur
|
_get_comp_words_by_ref cur
|
||||||
opts="--enabled --disabled --email --noemail --plack --noplack --sip --nosip --help -h"
|
opts="--enabled --disabled --email --noemail --plack --noplack --sip --nosip --help -h --elasticsearch --noelasticsearch"
|
||||||
|
|
||||||
# Build a list of the already used option switches
|
# Build a list of the already used option switches
|
||||||
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
||||||
|
@ -141,6 +141,10 @@ _koha_list()
|
||||||
substract="$substract -e --enabled"; ;;
|
substract="$substract -e --enabled"; ;;
|
||||||
--enabled)
|
--enabled)
|
||||||
substract="$substract -e --disabled"; ;;
|
substract="$substract -e --disabled"; ;;
|
||||||
|
--elasticsearch)
|
||||||
|
substract="$substract -e --noelasticsearch"; ;;
|
||||||
|
--noelasticsearch)
|
||||||
|
substract="$substract -e --elasticsearch"; ;;
|
||||||
--email)
|
--email)
|
||||||
substract="$substract -e --noemail"; ;;
|
substract="$substract -e --noemail"; ;;
|
||||||
--noemail)
|
--noemail)
|
||||||
|
|
113
debian/scripts/koha-list
vendored
113
debian/scripts/koha-list
vendored
|
@ -29,37 +29,21 @@ fi
|
||||||
|
|
||||||
show_instances()
|
show_instances()
|
||||||
{
|
{
|
||||||
local show=$1
|
|
||||||
local show_email=$2
|
|
||||||
local show_sip=$3
|
|
||||||
|
|
||||||
for instance in $( get_instances ); do
|
for instance in $( get_instances ); do
|
||||||
case $show in
|
case $show in
|
||||||
"all")
|
"all")
|
||||||
if instance_filter_email $instance $show_email && \
|
if filter_ok $instance; then
|
||||||
instance_filter_letsencrypt $instance $show_letsencrypt && \
|
|
||||||
instance_filter_plack $instance $show_plack && \
|
|
||||||
instance_filter_z3950 $instance $show_z3950 && \
|
|
||||||
instance_filter_sip $instance $show_sip; then
|
|
||||||
echo $instance
|
echo $instance
|
||||||
fi ;;
|
fi ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_enabled $instance; then
|
if is_enabled $instance; then
|
||||||
if instance_filter_email $instance $show_email && \
|
if filter_ok $instance; then
|
||||||
instance_filter_letsencrypt $instance $show_letsencrypt && \
|
|
||||||
instance_filter_plack $instance $show_plack && \
|
|
||||||
instance_filter_z3950 $instance $show_z3950 && \
|
|
||||||
instance_filter_sip $instance $show_sip; then
|
|
||||||
echo $instance
|
echo $instance
|
||||||
fi
|
fi
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_enabled $instance; then
|
if ! is_enabled $instance; then
|
||||||
if instance_filter_email $instance $show_email && \
|
if filter_ok $instance; then
|
||||||
instance_filter_letsencrypt $instance $show_letsencrypt && \
|
|
||||||
instance_filter_plack $instance $show_plack && \
|
|
||||||
instance_filter_z3950 $instance $show_z3950 && \
|
|
||||||
instance_filter_sip $instance $show_sip; then
|
|
||||||
echo $instance
|
echo $instance
|
||||||
fi
|
fi
|
||||||
fi ;;
|
fi ;;
|
||||||
|
@ -67,21 +51,35 @@ show_instances()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter_ok()
|
||||||
|
{
|
||||||
|
local instance=$1
|
||||||
|
|
||||||
|
if instance_filter_email $instance && \
|
||||||
|
instance_filter_elasticsearch $instance && \
|
||||||
|
instance_filter_letsencrypt $instance && \
|
||||||
|
instance_filter_plack $instance && \
|
||||||
|
instance_filter_z3950 $instance && \
|
||||||
|
instance_filter_sip $instance; then
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
instance_filter_sip()
|
instance_filter_sip()
|
||||||
{
|
{
|
||||||
local instancename=$1
|
local instance=$1
|
||||||
local show_sip=$2;
|
|
||||||
|
|
||||||
case $show_sip in
|
case $show_sip in
|
||||||
"all")
|
"all")
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_sip_enabled $instancename; then
|
if is_sip_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_sip_enabled $instancename; then
|
if ! is_sip_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -92,18 +90,17 @@ instance_filter_sip()
|
||||||
|
|
||||||
instance_filter_plack()
|
instance_filter_plack()
|
||||||
{
|
{
|
||||||
local instancename=$1
|
local instance=$1
|
||||||
local show_plack=$2;
|
|
||||||
|
|
||||||
case $show_plack in
|
case $show_plack in
|
||||||
"all")
|
"all")
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_plack_enabled $instancename; then
|
if is_plack_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_plack_enabled $instancename; then
|
if ! is_plack_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -114,18 +111,17 @@ instance_filter_plack()
|
||||||
|
|
||||||
instance_filter_letsencrypt()
|
instance_filter_letsencrypt()
|
||||||
{
|
{
|
||||||
local instancename=$1
|
local instance=$1
|
||||||
local show_letsencrypt=$2;
|
|
||||||
|
|
||||||
case $show_letsencrypt in
|
case $show_letsencrypt in
|
||||||
"all")
|
"all")
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_letsencrypt_enabled $instancename; then
|
if is_letsencrypt_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_letsencrypt_enabled $instancename; then
|
if ! is_letsencrypt_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -136,18 +132,17 @@ instance_filter_letsencrypt()
|
||||||
|
|
||||||
instance_filter_email()
|
instance_filter_email()
|
||||||
{
|
{
|
||||||
local instancename=$1
|
local instance=$1
|
||||||
local show_email=$2;
|
|
||||||
|
|
||||||
case $show_email in
|
case $show_email in
|
||||||
"all")
|
"all")
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_email_enabled $instancename; then
|
if is_email_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_email_enabled $instancename; then
|
if ! is_email_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -158,18 +153,38 @@ instance_filter_email()
|
||||||
|
|
||||||
instance_filter_z3950()
|
instance_filter_z3950()
|
||||||
{
|
{
|
||||||
local instancename=$1
|
local instance=$1
|
||||||
local show_z3950=$2;
|
|
||||||
|
|
||||||
case $show_z3950 in
|
case $show_z3950 in
|
||||||
"all")
|
"all")
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
"enabled")
|
"enabled")
|
||||||
if is_z3950_enabled $instancename; then
|
if is_z3950_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
"disabled")
|
"disabled")
|
||||||
if ! is_z3950_enabled $instancename; then
|
if ! is_z3950_enabled $instance; then
|
||||||
|
return 0
|
||||||
|
fi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Didn't match any criteria
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
instance_filter_elasticsearch()
|
||||||
|
{
|
||||||
|
local instance=$1
|
||||||
|
|
||||||
|
case $show_elasticsearch in
|
||||||
|
"all")
|
||||||
|
return 0 ;;
|
||||||
|
"enabled")
|
||||||
|
if is_elasticsearch_enabled $instance; then
|
||||||
|
return 0
|
||||||
|
fi ;;
|
||||||
|
"disabled")
|
||||||
|
if ! is_elasticsearch_enabled $instance; then
|
||||||
return 0
|
return 0
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -189,6 +204,17 @@ set_show()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_show_elasticsearch()
|
||||||
|
{
|
||||||
|
local elasticsearch_param=$1
|
||||||
|
|
||||||
|
if [ "$show_elasticsearch" = "all" ]; then
|
||||||
|
show_elasticsearch=$elasticsearch_param
|
||||||
|
else
|
||||||
|
die "Error: --elasticsearch and --noelasticsearch are mutually exclusive."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
set_show_email()
|
set_show_email()
|
||||||
{
|
{
|
||||||
local email_param=$1
|
local email_param=$1
|
||||||
|
@ -256,6 +282,8 @@ Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-
|
||||||
Options:
|
Options:
|
||||||
--enabled Show enabled instances
|
--enabled Show enabled instances
|
||||||
--disabled Show disabled instances
|
--disabled Show disabled instances
|
||||||
|
--elasticsearch Show instances with Elasticsearch enabled
|
||||||
|
--noelasticsarch Show instances with Elasticsearch disabled
|
||||||
--email Show instances with email enabled
|
--email Show instances with email enabled
|
||||||
--noemail Show instances with email disabled
|
--noemail Show instances with email disabled
|
||||||
--sip Show instances with SIP enabled
|
--sip Show instances with SIP enabled
|
||||||
|
@ -274,13 +302,14 @@ EOH
|
||||||
}
|
}
|
||||||
|
|
||||||
show="all"
|
show="all"
|
||||||
|
show_elasticsearch="all"
|
||||||
show_email="all"
|
show_email="all"
|
||||||
show_sip="all"
|
show_sip="all"
|
||||||
show_plack="all"
|
show_plack="all"
|
||||||
show_letsencrypt="all"
|
show_letsencrypt="all"
|
||||||
show_z3950="all"
|
show_z3950="all"
|
||||||
|
|
||||||
args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt,z3950,noz3950 -o h -n $0 -- "$@")
|
args=$(getopt -l help,enabled,disabled,elasticsearch,noelasticsearch,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt,z3950,noz3950 -o h -n $0 -- "$@")
|
||||||
set -- $args
|
set -- $args
|
||||||
|
|
||||||
while [ ! -z "$1" ]
|
while [ ! -z "$1" ]
|
||||||
|
@ -297,6 +326,8 @@ do
|
||||||
--noletsencrypt) set_show_letsencrypt "disabled" ;;
|
--noletsencrypt) set_show_letsencrypt "disabled" ;;
|
||||||
--z3950) set_show_z3950 "enabled" ;;
|
--z3950) set_show_z3950 "enabled" ;;
|
||||||
--noz3950) set_show_z3950 "disabled" ;;
|
--noz3950) set_show_z3950 "disabled" ;;
|
||||||
|
--elasticsearch) set_show_elasticsearch "enabled" ;;
|
||||||
|
--noelasticsearch) set_show_elasticsearch "disabled" ;;
|
||||||
--enabled) set_show "enabled" ;;
|
--enabled) set_show "enabled" ;;
|
||||||
--disabled) set_show "disabled" ;;
|
--disabled) set_show "disabled" ;;
|
||||||
*) break;;
|
*) break;;
|
||||||
|
@ -304,6 +335,6 @@ do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
show_instances $show $show_email $show_sip
|
show_instances
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue