Bug 8566 - Enable koha-foreach to insert the instancename into commands
Summary: Enable koha-foreach to insert the instancename into commands
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 8567
  Show dependency treegraph
 
Reported: 2012-08-03 09:25 UTC by Magnus Enger
Modified: 2015-06-04 23:32 UTC (History)
3 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
patch for feature update (1.79 KB, patch)
2014-06-26 06:43 UTC, Reed Wade
Details | Diff | Splinter Review
Bug 8566: Enable koha-foreach to insert the instancename into commands (2.06 KB, patch)
2014-06-26 08:30 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 8566: [SIGNED-OFF] Enable koha-foreach to insert the instancename into commands (2.08 KB, patch)
2014-06-26 08:31 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 8566: [SIGNED-OFF] Enable koha-foreach to insert the instancename into commands (2.13 KB, patch)
2014-06-26 22:28 UTC, Robin Sheat
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2012-08-03 09:25:02 UTC
The synopsis for koha-foreach looks like this: 

  koha-foreach [--enabled] [--email|--noemail] [command]

It is used e.g. in cron configs, like this: 

  koha-foreach --enabled /usr/share/koha/bin/cronjobs/fines.pl

It would be very useful if we could provide a placeholder in the command, which could then be replaced with the name of the current instance. Then we could do e.g.: 

  koha-foreach --enabled /usr/share/koha/bin/cronjobs/fines.pl --out /var/log/koha/__instancename__

and have fines.pl use the right directory for each instance.
Comment 1 Reed Wade 2014-06-26 06:43:29 UTC Comment hidden (obsolete)
Comment 2 Reed Wade 2014-06-26 06:44:39 UTC
I haven't submitted in a while. Let me know if I've borked a step.
Comment 3 Magnus Enger 2014-06-26 08:30:20 UTC Comment hidden (obsolete)
Comment 4 Magnus Enger 2014-06-26 08:31:03 UTC Comment hidden (obsolete)
Comment 5 Robin Sheat 2014-06-26 22:28:14 UTC
Created attachment 29309 [details] [review]
Bug 8566: [SIGNED-OFF] Enable koha-foreach to insert the instancename into commands

koha-foreach has been modified to replace __instancename__ with $name
on each iteration using sed.

The docbook file for koha-foreach has also been updated to reflect the
new functionality.

To test:

    koha-foreach ls -ld /etc/koha/sites/__instancename__

should list directories instead of giving an error message.

Signed-off-by: Magnus Enger <digitalutvikling@gmail.com>
The suggested example with ls works as expected, as does my
more complex example with fines.pl:

koha-foreach --enabled /usr/share/koha/bin/cronjobs/fines.pl \
--out /var/log/koha/__instancename__/

The man page looks good too.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 6 Tomás Cohen Arazi 2014-07-02 18:56:31 UTC
Patch pushed to master.

Thanks Reed!