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
36 for instance in $( get_instances ); do
39 if instance_filter_email $instance $show_email && \
40 instance_filter_letsencrypt $instance $show_letsencrypt && \
41 instance_filter_plack $instance $show_plack && \
42 instance_filter_sip $instance $show_sip; then
46 if is_enabled $instance; then
47 if instance_filter_email $instance $show_email && \
48 instance_filter_letsencrypt $instance $show_letsencrypt && \
49 instance_filter_plack $instance $show_plack && \
50 instance_filter_sip $instance $show_sip; then
55 if ! is_enabled $instance; then
56 if instance_filter_email $instance $show_email && \
57 instance_filter_letsencrypt $instance $show_letsencrypt && \
58 instance_filter_plack $instance $show_plack && \
59 instance_filter_sip $instance $show_sip; then
77 if is_sip_enabled $instancename; then
81 if ! is_sip_enabled $instancename; then
86 # Didn't match any criteria
90 instance_filter_plack()
99 if is_plack_enabled $instancename; then
103 if ! is_plack_enabled $instancename; then
108 # Didn't match any criteria
112 instance_filter_letsencrypt()
114 local instancename=$1
115 local show_letsencrypt=$2;
117 case $show_letsencrypt in
121 if is_letsencrypt_enabled $instancename; then
125 if ! is_letsencrypt_enabled $instancename; then
130 # Didn't match any criteria
134 instance_filter_email()
136 local instancename=$1
143 if is_email_enabled $instancename; then
147 if ! is_email_enabled $instancename; then
152 # Didn't match any criteria
160 if [ "$show" = "all" ]; then
163 die "Error: --enabled and --disabled are mutually exclusive."
171 if [ "$show_email" = "all" ]; then
172 show_email=$email_param
174 die "Error: --email and --noemail are mutually exclusive."
178 set_show_letsencrypt()
180 local letsencrypt_param=$1
182 if [ "$show_letsencrypt" = "all" ]; then
183 show_letsencrypt=$letsencrypt_param
185 die "Error: --letsencrypt and --noletsencrypt are mutually exclusive."
193 if [ "$show_plack" = "all" ]; then
194 show_plack=$plack_param
196 die "Error: --plack and --noplack are mutually exclusive."
204 if [ "$show_sip" = "all" ]; then
207 die "Error: --sip and --nosip are mutually exclusive."
216 Lists Koha instances, optionally only those that are enabled or have
219 Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-h]
221 --enabled Show enabled instances
222 --disabled Show disabled instances
223 --email Show instances with email enabled
224 --noemail Show instances with email disabled
225 --sip Show instances with SIP enabled
226 --nosip Show instances with SIP disabled
227 --plack Show instances with Plack enabled
228 --noplack Show instances with Plack disabled
229 --letsencrypt Show instances with letsencrypt enabled
230 --noletsencrypt Show instances with letsencrypt disabled
231 --help | -h Show this help
233 The filtering options can be combined, and you probably want to do this
234 (except --email and --noemail, or --enabled and --disabled, that's just silly.)
242 show_letsencrypt="all"
244 args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt -o h -n $0 -- "$@")
250 -h|--help) usage; exit;;
251 --email) set_show_email "enabled" ;;
252 --noemail) set_show_email "disabled" ;;
253 --sip) set_show_sip "enabled" ;;
254 --nosip) set_show_sip "disabled" ;;
255 --plack) set_show_plack "enabled" ;;
256 --noplack) set_show_plack "disabled" ;;
257 --letsencrypt) set_show_letsencrypt "enabled" ;;
258 --noletsencrypt) set_show_letsencrypt "disabled" ;;
259 --enabled) set_show "enabled" ;;
260 --disabled) set_show "disabled" ;;
266 show_instances $show $show_email $show_sip