Lines 49-54
is_email_enabled()
Link Here
|
49 |
fi |
49 |
fi |
50 |
} |
50 |
} |
51 |
|
51 |
|
|
|
52 |
is_sip_enabled() |
53 |
{ |
54 |
local instancename=$1 |
55 |
|
56 |
if [ -e /etc/koha/sites/$instancename/SIPconfig.xml ]; then |
57 |
return 0 |
58 |
else |
59 |
return 1 |
60 |
fi |
61 |
} |
62 |
|
52 |
get_instances() |
63 |
get_instances() |
53 |
{ |
64 |
{ |
54 |
find /etc/koha/sites -mindepth 1 -maxdepth 1\ |
65 |
find /etc/koha/sites -mindepth 1 -maxdepth 1\ |
Lines 59-98
show_instances()
Link Here
|
59 |
{ |
70 |
{ |
60 |
local show=$1 |
71 |
local show=$1 |
61 |
local show_email=$2 |
72 |
local show_email=$2 |
|
|
73 |
local show_sip=$3 |
62 |
|
74 |
|
63 |
for instance in $( get_instances ); do |
75 |
for instance in $( get_instances ); do |
64 |
case $show in |
76 |
case $show in |
65 |
"all") |
77 |
"all") |
66 |
show_instance_filter_email $instance $show_email;; |
78 |
if instance_filter_email $instance $show_email && \ |
|
|
79 |
instance_filter_sip $instance $show_sip; then |
80 |
echo $instance |
81 |
fi ;; |
67 |
"enabled") |
82 |
"enabled") |
68 |
if is_enabled $instance; then |
83 |
if is_enabled $instance; then |
69 |
show_instance_filter_email $instance $show_email |
84 |
if instance_filter_email $instance $show_email && \ |
|
|
85 |
instance_filter_sip $instance $show_sip; then |
86 |
echo $instance |
87 |
fi |
70 |
fi ;; |
88 |
fi ;; |
71 |
"disabled") |
89 |
"disabled") |
72 |
if ! is_enabled $instance; then |
90 |
if ! is_enabled $instance; then |
73 |
show_instance_filter_email $instance $show_email |
91 |
if instance_filter_email $instance $show_email && \ |
|
|
92 |
instance_filter_sip $instance $show_sip; then |
93 |
echo $instance |
94 |
fi |
74 |
fi ;; |
95 |
fi ;; |
75 |
esac |
96 |
esac |
76 |
done |
97 |
done |
77 |
} |
98 |
} |
78 |
|
99 |
|
79 |
show_instance_filter_email() |
100 |
|
|
|
101 |
instance_filter_sip() |
102 |
{ |
103 |
local instancename=$1 |
104 |
local show_sip=$2; |
105 |
|
106 |
case $show_sip in |
107 |
"all") |
108 |
return 0 ;; |
109 |
"enabled") |
110 |
if is_sip_enabled $instancename; then |
111 |
return 0 |
112 |
fi ;; |
113 |
"disabled") |
114 |
if ! is_sip_enabled $instancename; then |
115 |
return 0 |
116 |
fi ;; |
117 |
esac |
118 |
|
119 |
# Didn't match any criteria |
120 |
return 1 |
121 |
} |
122 |
|
123 |
instance_filter_email() |
80 |
{ |
124 |
{ |
81 |
local instancename=$1 |
125 |
local instancename=$1 |
82 |
local show_email=$2; |
126 |
local show_email=$2; |
83 |
|
127 |
|
84 |
case $show_email in |
128 |
case $show_email in |
85 |
"all") |
129 |
"all") |
86 |
echo $instancename ;; |
130 |
return 0 ;; |
87 |
"enabled") |
131 |
"enabled") |
88 |
if is_email_enabled $instancename; then |
132 |
if is_email_enabled $instancename; then |
89 |
echo $instancename |
133 |
return 0 |
90 |
fi ;; |
134 |
fi ;; |
91 |
"disabled") |
135 |
"disabled") |
92 |
if ! is_email_enabled $instancename; then |
136 |
if ! is_email_enabled $instancename; then |
93 |
echo $instancename |
137 |
return 0 |
94 |
fi ;; |
138 |
fi ;; |
95 |
esac |
139 |
esac |
|
|
140 |
|
141 |
# Didn't match any criteria |
142 |
return 1 |
96 |
} |
143 |
} |
97 |
|
144 |
|
98 |
set_show() |
145 |
set_show() |
Lines 117-155
set_show_email()
Link Here
|
117 |
fi |
164 |
fi |
118 |
} |
165 |
} |
119 |
|
166 |
|
|
|
167 |
set_show_sip() |
168 |
{ |
169 |
local sip_param=$1 |
170 |
|
171 |
if [ "$show_sip" = "all" ]; then |
172 |
show_sip=$sip_param |
173 |
else |
174 |
die "Error: --sip and --nosip are mutually exclusive." |
175 |
fi |
176 |
} |
177 |
|
120 |
usage() |
178 |
usage() |
121 |
{ |
179 |
{ |
122 |
local scriptname=$0 |
180 |
local scriptname=$0 |
123 |
|
181 |
|
124 |
echo <<eoh |
182 |
cat <<EOH |
125 |
Lists Koha instances, optionally only those that are enabled or have |
183 |
Lists Koha instances, optionally only those that are enabled or have |
126 |
email turned on. |
184 |
email turned on. |
127 |
|
185 |
|
128 |
Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [-h] |
186 |
Usage: $scriptname [--enabled|--disabled] [--email|--noemail] [--sip|--nosip] [-h] |
129 |
Options: |
187 |
Options: |
130 |
--enabled only show instances that are enabled |
188 |
--enabled Only show instances that are enabled |
131 |
--disabled only show instances that are disabled |
189 |
--disabled Only show instances that are disabled |
132 |
--email only show instances that have email enabled |
190 |
--email Only show instances that have email enabled |
133 |
--noemail only show instances that do not have email enabled |
191 |
--noemail Only show instances that do not have email enabled |
134 |
-h this help |
192 |
--sip Only show instances that have sip enabled |
|
|
193 |
--nosip Only show instances that do not have sip enabled |
194 |
--help | -h Show this help |
135 |
|
195 |
|
136 |
The filtering options can be combined, and you probably want to do this |
196 |
The filtering options can be combined, and you probably want to do this |
137 |
(except --email and --noemail, or --enabled and --disabled, that's just silly.) |
197 |
(except --email and --noemail, or --enabled and --disabled, that's just silly.) |
138 |
eoh |
198 |
EOH |
139 |
} |
199 |
} |
140 |
|
200 |
|
141 |
show="all" |
201 |
show="all" |
142 |
show_email="all" |
202 |
show_email="all" |
|
|
203 |
show_sip="all" |
143 |
|
204 |
|
144 |
args=$(getopt -l enabled,disabled,email,noemail -o h -n $0 -- "$@") |
205 |
args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip -o h -n $0 -- "$@") |
145 |
set -- $args |
206 |
set -- $args |
146 |
|
207 |
|
147 |
while [ ! -z "$1" ] |
208 |
while [ ! -z "$1" ] |
148 |
do |
209 |
do |
149 |
case "$1" in |
210 |
case "$1" in |
150 |
-h) usage; exit;; |
211 |
-h|--help) usage; exit;; |
151 |
--email) set_show_email "enabled" ;; |
212 |
--email) set_show_email "enabled" ;; |
152 |
--noemail) set_show_email "disabled" ;; |
213 |
--noemail) set_show_email "disabled" ;; |
|
|
214 |
--sip) set_show_sip "enabled" ;; |
215 |
--nosip) set_show_sip "disabled" ;; |
153 |
--enabled) set_show "enabled" ;; |
216 |
--enabled) set_show "enabled" ;; |
154 |
--disabled) set_show "disabled" ;; |
217 |
--disabled) set_show "disabled" ;; |
155 |
*) break;; |
218 |
*) break;; |
Lines 157-162
do
Link Here
|
157 |
shift |
220 |
shift |
158 |
done |
221 |
done |
159 |
|
222 |
|
160 |
show_instances $show $show_email |
223 |
show_instances $show $show_email $show_sip |
161 |
|
224 |
|
162 |
exit 0 |
225 |
exit 0 |
163 |
- |
|
|