Bug 8566

Summary: Enable koha-foreach to insert the instancename into commands
Product: Koha Reporter: Magnus Enger <magnus>
Component: PackagingAssignee: Bugs List <koha-bugs>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: reed, robin, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 8567    
Attachments: patch for feature update
Bug 8566: Enable koha-foreach to insert the instancename into commands
Bug 8566: [SIGNED-OFF] Enable koha-foreach to insert the instancename into commands
Bug 8566: [SIGNED-OFF] Enable koha-foreach to insert the instancename into commands

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!