Bug 18709: Make koha-foreach use koha-shell internally
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 27 Jun 2017 14:55:45 +0000 (11:55 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 10 Apr 2018 07:15:10 +0000 (09:15 +0200)
commitd6367c4b431091ef90263f0d49d5dc3d8ef7996c
tree307a5f3b5b5f862271c03c73f395bb2072184433
parent6e58877b7d8526228003d4dadb51977d44dbe653
Bug 18709: Make koha-foreach use koha-shell internally

This patch simplifies the koha-foreach script, making it use koha-shell
to gain instance privileges and have all environment variables set.

To test:
- Apply the patch
- Have one or more instances created (kohadev already exists in kohadevbox, add
  another onewith $ sudo koha-create --create-db test)
- Run:
  $ sudo kohaclone/debian/scripts/koha-foreach echo "This is instance __instancename__"
=> SUCCESS: The script runs gracefuly, and outputs something like:
This is instance kohadev
This is instance test
  Note: this means the command was executed for each instance and the current behaviour
        of replacing the placeholder __instancename__ for the actual instance name still
        works as expected.
- You can try the different filter switches, but the logic has not been touched. only the
  command call.
- Sign off :-D

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 75994dc94a2f5d1a500a7789ed113575c49f8b51)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
debian/scripts/koha-foreach