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.
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
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>
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>
Pushed to master for 17.11, thanks to everybody involved!
Pushed to 17.05.x for v17.05.11