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_z3950
$instance $show_z3950 && \
43 instance_filter_sip
$instance $show_sip; then
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
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
80 if is_sip_enabled
$instancename; then
84 if ! is_sip_enabled
$instancename; then
89 # Didn't match any criteria
93 instance_filter_plack
()
102 if is_plack_enabled
$instancename; then
106 if ! is_plack_enabled
$instancename; then
111 # Didn't match any criteria
115 instance_filter_letsencrypt
()
117 local instancename
=$1
118 local show_letsencrypt
=$2;
120 case $show_letsencrypt in
124 if is_letsencrypt_enabled
$instancename; then
128 if ! is_letsencrypt_enabled
$instancename; then
133 # Didn't match any criteria
137 instance_filter_email
()
139 local instancename
=$1
146 if is_email_enabled
$instancename; then
150 if ! is_email_enabled
$instancename; then
155 # Didn't match any criteria
159 instance_filter_z3950
()
161 local instancename
=$1
168 if is_z3950_enabled
$instancename; then
172 if ! is_z3950_enabled
$instancename; then
177 # Didn't match any criteria
185 if [ "$show" = "all" ]; then
188 die
"Error: --enabled and --disabled are mutually exclusive."
196 if [ "$show_email" = "all" ]; then
197 show_email
=$email_param
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
210 die
"Error: --letsencrypt and --noletsencrypt are mutually exclusive."
218 if [ "$show_plack" = "all" ]; then
219 show_plack
=$plack_param
221 die
"Error: --plack and --noplack are mutually exclusive."
229 if [ "$show_sip" = "all" ]; then
232 die
"Error: --sip and --nosip are mutually exclusive."
240 if [ "$show_z3950" = "all" ]; then
241 show_z3950
=$z3950_param
243 die
"Error: --z3950 and --noz3950 are mutually exclusive."
252 Lists Koha instances, optionally only those that are enabled or have
255 Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-h]
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.)
280 show_letsencrypt
="all"
283 args
=$
(getopt
-l help,enabled
,disabled
,email
,noemail
,sip
,nosip
,plack
,noplack
,letsencrypt
,noletsencrypt
,z3950
,noz3950
-o h
-n $0 -- "$@")
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" ;;
307 show_instances
$show $show_email $show_sip