2 # koha-foreach -- run a command for each Koha instance
3 # Copyright 2010 Catalyst IT, Ltd
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.
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/>.
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"
27 echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
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" ;;
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
68 echo "${name}: $rv status returned by \"${cmd}\""
71 # Go back to the original dir if required
72 [ "$chdir" != "no" ] && cd "$starting_dir"