Bug 18709 - koha-foreach should use koha-shell, internally
Summary: koha-foreach should use koha-shell, internally
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-31 14:36 UTC by Tomás Cohen Arazi
Modified: 2019-10-14 19:57 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18709: Make koha-foreach use koha-shell internally (1.98 KB, patch)
2017-06-27 15:02 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 18709: Make koha-foreach use koha-shell internally (2.06 KB, patch)
2017-09-26 17:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18709: Make koha-foreach use koha-shell internally (2.11 KB, patch)
2017-10-11 00:16 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2017-05-31 14:36:47 UTC
Highlighted by bug 17717, koha-foreach is currently taking care of crafting all env variables and call sudo to run the required tasks.

We should definitely call koha-shell in there, and have a single place in which to take care of this logic.
Comment 1 Tomás Cohen Arazi 2017-06-27 15:02:47 UTC
Created attachment 64680 [details] [review]
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
Comment 2 Jonathan Druart 2017-09-26 17:46:33 UTC
Created attachment 67372 [details] [review]
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>
Comment 3 Nick Clemens 2017-10-11 00:16:46 UTC
Created attachment 67920 [details] [review]
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>
Comment 4 Jonathan Druart 2017-10-11 16:53:51 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 5 Fridolin Somers 2018-04-10 07:17:39 UTC
Pushed to 17.05.x for v17.05.11