Bug 25896: Add missing closing </td> tag
[koha.git] / debian / scripts / koha-list
bloba88d37b89297ab6e4379ed71a77f616ffe1fe696
1 #!/bin/sh
3 # koha-list -- List all Koha instances.
4 # Copyright 2010 Catalyst IT, Ltd
5 #
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/>.
20 set -e
22 # include helper functions
23 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
24 . "/usr/share/koha/bin/koha-functions.sh"
25 else
26 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
27 exit 1
30 show_instances()
32 local show=$1
33 local show_email=$2
34 local show_sip=$3
36 for instance in $( get_instances ); do
37 case $show in
38 "all")
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_z3950 $instance $show_z3950 && \
43 instance_filter_sip $instance $show_sip; then
44 echo $instance
45 fi ;;
46 "enabled")
47 if is_enabled $instance; then
48 if instance_filter_email $instance $show_email && \
49 instance_filter_letsencrypt $instance $show_letsencrypt && \
50 instance_filter_plack $instance $show_plack && \
51 instance_filter_z3950 $instance $show_z3950 && \
52 instance_filter_sip $instance $show_sip; then
53 echo $instance
55 fi ;;
56 "disabled")
57 if ! is_enabled $instance; then
58 if instance_filter_email $instance $show_email && \
59 instance_filter_letsencrypt $instance $show_letsencrypt && \
60 instance_filter_plack $instance $show_plack && \
61 instance_filter_z3950 $instance $show_z3950 && \
62 instance_filter_sip $instance $show_sip; then
63 echo $instance
65 fi ;;
66 esac
67 done
71 instance_filter_sip()
73 local instancename=$1
74 local show_sip=$2;
76 case $show_sip in
77 "all")
78 return 0 ;;
79 "enabled")
80 if is_sip_enabled $instancename; then
81 return 0
82 fi ;;
83 "disabled")
84 if ! is_sip_enabled $instancename; then
85 return 0
86 fi ;;
87 esac
89 # Didn't match any criteria
90 return 1
93 instance_filter_plack()
95 local instancename=$1
96 local show_plack=$2;
98 case $show_plack in
99 "all")
100 return 0 ;;
101 "enabled")
102 if is_plack_enabled $instancename; then
103 return 0
104 fi ;;
105 "disabled")
106 if ! is_plack_enabled $instancename; then
107 return 0
108 fi ;;
109 esac
111 # Didn't match any criteria
112 return 1
115 instance_filter_letsencrypt()
117 local instancename=$1
118 local show_letsencrypt=$2;
120 case $show_letsencrypt in
121 "all")
122 return 0 ;;
123 "enabled")
124 if is_letsencrypt_enabled $instancename; then
125 return 0
126 fi ;;
127 "disabled")
128 if ! is_letsencrypt_enabled $instancename; then
129 return 0
130 fi ;;
131 esac
133 # Didn't match any criteria
134 return 1
137 instance_filter_email()
139 local instancename=$1
140 local show_email=$2;
142 case $show_email in
143 "all")
144 return 0 ;;
145 "enabled")
146 if is_email_enabled $instancename; then
147 return 0
148 fi ;;
149 "disabled")
150 if ! is_email_enabled $instancename; then
151 return 0
152 fi ;;
153 esac
155 # Didn't match any criteria
156 return 1
159 instance_filter_z3950()
161 local instancename=$1
162 local show_z3950=$2;
164 case $show_z3950 in
165 "all")
166 return 0 ;;
167 "enabled")
168 if is_z3950_enabled $instancename; then
169 return 0
170 fi ;;
171 "disabled")
172 if ! is_z3950_enabled $instancename; then
173 return 0
174 fi ;;
175 esac
177 # Didn't match any criteria
178 return 1
181 set_show()
183 local show_param=$1
185 if [ "$show" = "all" ]; then
186 show=$show_param
187 else
188 die "Error: --enabled and --disabled are mutually exclusive."
192 set_show_email()
194 local email_param=$1
196 if [ "$show_email" = "all" ]; then
197 show_email=$email_param
198 else
199 die "Error: --email and --noemail are mutually exclusive."
203 set_show_letsencrypt()
205 local letsencrypt_param=$1
207 if [ "$show_letsencrypt" = "all" ]; then
208 show_letsencrypt=$letsencrypt_param
209 else
210 die "Error: --letsencrypt and --noletsencrypt are mutually exclusive."
214 set_show_plack()
216 local plack_param=$1
218 if [ "$show_plack" = "all" ]; then
219 show_plack=$plack_param
220 else
221 die "Error: --plack and --noplack are mutually exclusive."
225 set_show_sip()
227 local sip_param=$1
229 if [ "$show_sip" = "all" ]; then
230 show_sip=$sip_param
231 else
232 die "Error: --sip and --nosip are mutually exclusive."
236 set_show_z3950()
238 local z3950_param=$1
240 if [ "$show_z3950" = "all" ]; then
241 show_z3950=$z3950_param
242 else
243 die "Error: --z3950 and --noz3950 are mutually exclusive."
247 usage()
249 local scriptname=$0
251 cat <<EOH
252 Lists Koha instances, optionally only those that are enabled or have
253 email turned on.
255 Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-h]
256 Options:
257 --enabled Show enabled instances
258 --disabled Show disabled instances
259 --email Show instances with email enabled
260 --noemail Show instances with email disabled
261 --sip Show instances with SIP enabled
262 --nosip Show instances with SIP disabled
263 --plack Show instances with Plack enabled
264 --noplack Show instances with Plack disabled
265 --letsencrypt Show instances with letsencrypt enabled
266 --noletsencrypt Show instances with letsencrypt disabled
267 --z3950 Show instances with Z39.50/SRU enabled
268 --noz3950 Show instances with Z39.50/SRU disabled
269 --help | -h Show this help
271 The filtering options can be combined, and you probably want to do this
272 (except --email and --noemail, or --enabled and --disabled, that's just silly.)
276 show="all"
277 show_email="all"
278 show_sip="all"
279 show_plack="all"
280 show_letsencrypt="all"
281 show_z3950="all"
283 args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plack,noplack,letsencrypt,noletsencrypt,z3950,noz3950 -o h -n $0 -- "$@")
284 set -- $args
286 while [ ! -z "$1" ]
288 case "$1" in
289 -h|--help) usage; exit;;
290 --email) set_show_email "enabled" ;;
291 --noemail) set_show_email "disabled" ;;
292 --sip) set_show_sip "enabled" ;;
293 --nosip) set_show_sip "disabled" ;;
294 --plack) set_show_plack "enabled" ;;
295 --noplack) set_show_plack "disabled" ;;
296 --letsencrypt) set_show_letsencrypt "enabled" ;;
297 --noletsencrypt) set_show_letsencrypt "disabled" ;;
298 --z3950) set_show_z3950 "enabled" ;;
299 --noz3950) set_show_z3950 "disabled" ;;
300 --enabled) set_show "enabled" ;;
301 --disabled) set_show "disabled" ;;
302 *) break;;
303 esac
304 shift
305 done
307 show_instances $show $show_email $show_sip
309 exit 0