Bug 25671 - Install 1 Koha plugin for X Koha instances using the CLI
Summary: Install 1 Koha plugin for X Koha instances using the CLI
Status: RESOLVED DUPLICATE of bug 28498
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-04 00:20 UTC by David Cook
Modified: 2022-06-22 00:29 UTC (History)
3 users (show)

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


Attachments
WIP (9.78 KB, patch)
2020-07-23 03:57 UTC, David Cook
Details | Diff | Splinter Review
WIP (9.78 KB, patch)
2020-07-23 03:58 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2020-06-04 00:20:53 UTC
I want to create the following:

koha-plugin-install <instance> <plugin.kpz>

You'd have 1 KPZ package, and you'd be able to add/upload/install it into an instance from the command line.

This would allow a sysadmin to easily automate the installation of plugins across Koha instances from the server side.
Comment 1 David Cook 2020-06-04 00:27:05 UTC
It would also be interesting to use "koha-plugin-install <instance> <http://repo.org/releases/plugin.kpz>"

That could make plugin management even easier.
Comment 2 David Cook 2020-07-08 12:16:30 UTC
Actually, I think the syntax would be "koha-plugin --install <plugin> <instance1> <instance2>"
Comment 3 David Cook 2020-07-09 12:13:43 UTC
Turns out that the easier way to do this was to create "misc/koha_plugin.pl" which will be called by koha-plugin...

koha-shell -c "perl misc/koha_plugin.pl --uninstall Koha::Plugin::Com::ByWaterSolutions::CoverFlow" kohadev
Comment 4 David Cook 2020-07-09 13:09:02 UTC
koha-shell -c "perl misc/koha_plugin.pl --install https://github.com/bywatersolutions/koha-plugin-coverflow/releases/download/v2.4.35/koha-coverflow-plugin-v2.4.35.kpz" kohadev

koha-shell -c "perl misc/koha_plugin.pl --install https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.39/koha-plugin-kitchen-sink-v2.1.39.kpz" kohadev

koha-shell -c "perl misc/koha_plugin.pl --uninstall Koha::Plugin::Com::ByWaterSolutions::CoverFlow" kohadev

koha-shell -c "perl misc/koha_plugin.pl --uninstall Koha::Plugin::Com::ByWaterSolutions::KitchenSink" kohadev
Comment 5 David Cook 2020-07-09 13:12:03 UTC
I'm also going to make it so that you can provide a KPZ file or an unzipped KPZ, so misc/koha_plugin.pl will be very flexible in terms of inputs.

The Debian script koha-plugin will download plugins over HTTP/HTTPS, and then unpack downloaded/local KPZ files into a staging directory.

The staging directory will then be copied to each instance specified.

It should be pretty sweet.

I want to add enable/disable options as well at some point, but that's not critical yet.
Comment 6 David Cook 2020-07-09 13:27:43 UTC
The following would work too but it wouldn't be efficient with a KPZ file or a HTTP(S) URL, because it would be re-downloading and/or re-unzipping every time:

koha-foreach perl misc/koha_plugin.pl --install https://github.com/bywatersolutions/koha-plugin-coverflow/releases/download/v2.4.35/koha-coverflow-plugin-v2.4.35.kpz

koha-foreach perl misc/koha_plugin.pl --uninstall Koha::Plugin::Com::ByWaterSolutions::CoverFlow

That said, it could be done with an unzipped plugin. That could be interesting. You wouldn't even need a KPZ file. You could point it right at a git checkout for instance. (That could actually be really useful from a Koha plugin development point of view as well.)

--

Perhaps I should rename misc/koha_plugin.pl to misc/koha_plugin_manager.pl. 

--

A goal of mine is to use this management feature to actually install a Koha Plugin for all my many libraries which is itself a Web-based Koha Plugin manager (inspired by the "Game Package Registry for Unity release" from Google for the Unity IDE). That Web-based Koha Plugin manager will then easily let Koha intranet users decide which plugins they want to install, but it'll only include a list of curated plugins.

Alternatively, I might use this management feature to install Koha plugins which used to be local customizations, and popular third-party plugins like Bywater's CoverFlow. 

Ultimately, I think we need a tool like this for dealing with plugins on any kind of scale that becomes manually unmanageable (e.g. 40 instances, 80 instances, etc.)
Comment 7 David Cook 2020-07-09 13:42:31 UTC
The code is still WIP, but I probably won't get back to this for a week or two. 

Looking forward to getting back to this though.
Comment 8 David Cook 2020-07-23 03:57:19 UTC
Created attachment 107210 [details] [review]
WIP
Comment 9 David Cook 2020-07-23 03:58:02 UTC
Created attachment 107211 [details] [review]
WIP

This is just my current work in progress. It's nearly done, but I haven't had time to
complete it yet.
Comment 10 David Cook 2021-06-02 02:46:14 UTC

*** This bug has been marked as a duplicate of bug 28498 ***
Comment 11 Tomás Cohen Arazi 2021-06-02 02:50:15 UTC
I didn't know or heard about this before. Will be looking at this code.
Comment 12 David Cook 2021-06-02 02:57:18 UTC
(In reply to Tomás Cohen Arazi from comment #11)
> I didn't know or heard about this before. Will be looking at this code.

<3