3 # koha-list -- List all Koha instances.
4 # Copyright 2010 Catalyst IT, Ltd
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # include helper functions
23 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
24 . "/usr/share/koha/bin/koha-functions.sh"
26 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
32 for instance in $( get_instances ); do
35 if filter_ok $instance; then
39 if is_enabled $instance; then
40 if filter_ok $instance; then
45 if ! is_enabled $instance; then
46 if filter_ok $instance; then
58 if instance_filter_email $instance && \
59 instance_filter_elasticsearch $instance && \
60 instance_filter_letsencrypt $instance && \
61 instance_filter_plack $instance && \
62 instance_filter_z3950 $instance && \
63 instance_filter_sip $instance; then
78 if is_sip_enabled $instance; then
82 if ! is_sip_enabled $instance; then
87 # Didn't match any criteria
91 instance_filter_plack()
99 if is_plack_enabled $instance; then
103 if ! is_plack_enabled $instance; then
108 # Didn't match any criteria
112 instance_filter_letsencrypt()
116 case $show_letsencrypt in
120 if is_letsencrypt_enabled $instance; then
124 if ! is_letsencrypt_enabled $instance; then
129 # Didn't match any criteria
133 instance_filter_email()
141 if is_email_enabled $instance; then
145 if ! is_email_enabled $instance; then
150 # Didn't match any criteria
154 instance_filter_z3950()
162 if is_z3950_enabled $instance; then
166 if ! is_z3950_enabled $instance; then
171 # Didn't match any criteria
175 instance_filter_elasticsearch()
179 case $show_elasticsearch in
183 if is_elasticsearch_enabled $instance; then
187 if ! is_elasticsearch_enabled $instance; then
192 # Didn't match any criteria
200 if [ "$show" = "all" ]; then
203 die "Error: --enabled and --disabled are mutually exclusive."
207 set_show_elasticsearch()
209 local elasticsearch_param=$1
211 if [ "$show_elasticsearch" = "all" ]; then
212 show_elasticsearch=$elasticsearch_param
214 die "Error: --elasticsearch and --noelasticsearch are mutually exclusive."
222 if [ "$show_email" = "all" ]; then
223 show_email=$email_param
225 die "Error: --email and --noemail are mutually exclusive."
229 set_show_letsencrypt()
231 local letsencrypt_param=$1
233 if [ "$show_letsencrypt" = "all" ]; then
234 show_letsencrypt=$letsencrypt_param
236 die "Error: --letsencrypt and --noletsencrypt are mutually exclusive."
244 if [ "$show_plack" = "all" ]; then
245 show_plack=$plack_param
247 die "Error: --plack and --noplack are mutually exclusive."
255 if [ "$show_sip" = "all" ]; then
258 die "Error: --sip and --nosip are mutually exclusive."
266 if [ "$show_z3950" = "all" ]; then
267 show_z3950=$z3950_param
269 die "Error: --z3950 and --noz3950 are mutually exclusive."
278 Lists Koha instances, optionally only those that are enabled or have
281 Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-h]
283 --enabled Show enabled instances
284 --disabled Show disabled instances
285 --elasticsearch Show instances with Elasticsearch enabled
286 --noelasticsarch Show instances with Elasticsearch disabled
287 --email Show instances with email enabled
288 --noemail Show instances with email disabled
289 --sip Show instances with SIP enabled
290 --nosip Show instances with SIP disabled
291 --plack Show instances with Plack enabled
292 --noplack Show instances with Plack disabled
293 --letsencrypt Show instances with letsencrypt enabled
294 --noletsencrypt Show instances with letsencrypt disabled
295 --z3950 Show instances with Z39.50/SRU enabled
296 --noz3950 Show instances with Z39.50/SRU disabled
297 --help | -h Show this help
299 The filtering options can be combined, and you probably want to do this
300 (except --email and --noemail, or --enabled and --disabled, that's just silly.)
305 show_elasticsearch="all"
309 show_letsencrypt="all"
312 args=$(getopt -l help,enabled,disabled,elasticsearch,noelasticsearch,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt,z3950,noz3950 -o h -n $0 -- "$@")
318 -h|--help) usage; exit;;
319 --email) set_show_email "enabled" ;;
320 --noemail) set_show_email "disabled" ;;
321 --sip) set_show_sip "enabled" ;;
322 --nosip) set_show_sip "disabled" ;;
323 --plack) set_show_plack "enabled" ;;
324 --noplack) set_show_plack "disabled" ;;
325 --letsencrypt) set_show_letsencrypt "enabled" ;;
326 --noletsencrypt) set_show_letsencrypt "disabled" ;;
327 --z3950) set_show_z3950 "enabled" ;;
328 --noz3950) set_show_z3950 "disabled" ;;
329 --elasticsearch) set_show_elasticsearch "enabled" ;;
330 --noelasticsearch) set_show_elasticsearch "disabled" ;;
331 --enabled) set_show "enabled" ;;
332 --disabled) set_show "disabled" ;;