Bug 25950: Remove <client> in X-Forwarded-For from proxy tests
[koha.git] / debian / scripts / koha-foreach
blob2f5a150fcbd46e4a2f64805fa8f3984ff33b2a24
1 #!/bin/sh
2 # koha-foreach -- run a command for each Koha instance
3 # Copyright 2010 Catalyst IT, Ltd
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 set -e
20 # Read configuration variable file if it is present
21 [ -r /etc/default/koha-common ] && . /etc/default/koha-common
23 # include helper functions
24 if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
25 . "/usr/share/koha/bin/koha-functions.sh"
26 else
27 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
28 exit 1
31 chdir="no"
32 starting_dir=$(pwd)
34 listopts=""
35 while [ ! -z "$1" ]
37 case "$1" in
38 --chdir) chdir="yes";;
39 --email) listopts="$listopts --email";;
40 --noemail) listopts="$listopts --noemail";;
41 --enabled) listopts="$listopts --enabled";;
42 --disabled) listopts="$listopts --disabled";;
43 --sip) listopts="$listopts --sip";;
44 --nosip) listopts="$listopts --nosip";;
45 --plack) listopts="$listopts --plack";;
46 --noplack) listopts="$listopts --noplack";;
47 --letsencrypt) listopts="$listopts --letsencrypt" ;;
48 --noletsencrypt) listopts="$listopts --noletsencrypt" ;;
49 *) break;;
50 esac
51 shift
52 done
54 for name in $(koha-list $listopts)
56 # Replace the __instancename__ placeholder for the instance name (Bug 8566)
57 cmd=`echo "$@" | sed -e s/__instancename__/${name}/g`
59 if [ "${cmd}" != "" ]; then
61 # Change to the instance's home dir if required
62 [ "$chdir" != "no" ] && eval cd ~$name"-koha"
64 if koha-shell ${name} -c "${cmd}"; then
65 : #noop
66 else
67 rv=$?
68 echo "${name}: $rv status returned by \"${cmd}\""
71 # Go back to the original dir if required
72 [ "$chdir" != "no" ] && cd "$starting_dir"
74 done