Bug 12805

Summary: Proposed changes to Koha plugins system (.KPZ) structure
Product: Koha Reporter: Indranil Das Gupta <indradg>
Component: ToolsAssignee: Indranil Das Gupta <indradg>
Status: Patch doesn't apply --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: chris, dcook, gmcharlt, indradg, josef.moravec, kyle, magnus, mtompset, robin, viktor.sarge
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Adds koha-enable-plugins and koha-disable-plugins scripts

Description Indranil Das Gupta 2014-08-21 22:13:24 UTC
In present scenario, the <pluginsdir> as per git install is located at /var/lib/plugins and per the Koha manual should be set up at /var/lib/koha/plugin.

That makes it a shared directory, and a problem with multi-tenanted installations. Removable of the plugin by Client A, results in it being removed for everyone else. Same goes for installation of new plugins. These may not have been vetted or required by other clients / sites sharing the installation.

Further, while the git based dev installation and the tarball installation have the <pluginsdir> defined in their respective 'skel' structures, this is missing the .deb packages.

So, I propose the following changes:

1) move <pluginsdir> to a site-specific directory i.e. /var/lib/koha/<site>/plugins 

Rationale: 

(a) allow for security-vetted and need-based plugin upload and segregation; 
(b) "UseKohaPlugins" is classed under site-specific "Enhanced Content" sysprefs;
(c) allow for easy resolution of AssignUserId apache directive in case of git installs (on a git install, .kpz uploads failed by default, citing apache doesn't own the directory);

2) add a 'koha-enable-plugins' shell script as part of the command-line tools.

Since, the plugins module was primarily Kyle's baby, I would like to hear back from him and others on this, before proceeding.

thanks
-indra
Comment 1 Robin Sheat 2014-08-21 23:44:48 UTC
1) is exactly how the packages do it now,
2) I don't see the need for this. At the moment you edit koha-conf.xml and set enable_plugins to 1 and that's all that's needed. koha-enable-plugins would just do that, but I feel it's doing such a small thing that it may as well be just the edit.
Comment 2 Robin Sheat 2014-08-21 23:46:18 UTC
One change I would like is supporting .tar.gz, .zip is such a wrong idea on linux systems. But that's probably its own bug :)
Comment 3 Indranil Das Gupta 2014-08-22 03:32:26 UTC
(In reply to Robin Sheat from comment #1)
> 1) is exactly how the packages do it now,

Mea culpa! Got that one clarified at #koha :-)

> 2) I don't see the need for this. At the moment you edit koha-conf.xml and
> set enable_plugins to 1 and that's all that's needed. koha-enable-plugins
> would just do that, but I feel it's doing such a small thing that it may as
> well be just the edit.

Automation and ease-of-use. With newbie users that I'm training up on Ubuntu/Koha combination, it is easier to have them run a "command" rather than fire up an editor, locate the line and change 0 to 1. FWIW, these are not technically savvy people and I've faced several cases of accidental deletion of other crucial lines / insertion of extraneous characters while making these small changes. These are largely train-and-let-go users whose only tech support is via telephone. The installations typically do not have Internet access.

But yes, this is a niche case, and perhaps do not map into regular Koha users.
Comment 4 Robin Sheat 2014-08-22 03:38:39 UTC
I'm OK with having the script created, that's no problem. If someone writes it, I certainly wouldn't veto it :)

But be aware that installing plugins may require some additional commandline stuff too, chmod'ing files etc. 

Due to them being in a zip file, they can end up installed with the most unsafe permissions possible, and that must be fixed from the command line. Also, some scripts may need to be made executable.
Comment 5 Viktor Sarge 2014-08-22 07:17:56 UTC
I can only provide partial feedback here. An optional command line tool would be a welcome addition. It's practical when you are afraid to to mess the file up, while still making it possible to edit it manually and learn a little more about whats going on under the hood.
Comment 6 Indranil Das Gupta 2014-08-22 21:31:38 UTC
Created attachment 31112 [details] [review]
Adds koha-enable-plugins and koha-disable-plugins scripts

Command-line koha-* script to toggle <enable_plugins> definition in
site specific koha-conf.xml; also to add plugins listing to existing
koha-list command. These files are expected to be used for a .deb
package based installation of Koha

Test plan:

1) Have a koha-common setup installed
2) Apply the patch and build a package for it.
3) Install it.
4) Verify that /yazgfz/config/enable_plugins is being toggled correctly
   when koha-enable-plugins and koha-disable-plugins are being called
   respectively.

-idg
Comment 7 Robin Sheat 2014-08-23 04:22:07 UTC
While I haven't tested it yet, this patch looks like a good approach to me.
Comment 8 Magnus Enger 2014-08-26 09:49:36 UTC
(In reply to Viktor Sarge from comment #5)
> I can only provide partial feedback here. An optional command line tool
> would be a welcome addition. It's practical when you are afraid to to mess
> the file up, while still making it possible to edit it manually and learn a
> little more about whats going on under the hood.

This got me thinking about the possibilities of adding a general purpose koha-config script. See bug 12824 for some suggestions/questions.
Comment 9 Magnus Enger 2016-10-18 09:12:49 UTC
Looks like this has a patch that needs signoff. Changing the status accordingly.
Comment 10 Magnus Enger 2016-10-18 09:16:55 UTC
The new scripts need to be documented in man pages, similar to the existing scripts.
Comment 11 Mark Tompsett 2017-01-10 06:10:55 UTC
With plack changes and the like, this no longer applies. :(
Tinkered with getting it up, but not finished, so marking does not apply until someone rebases or fixes it. :)
Comment 12 Josef Moravec 2018-12-11 06:53:51 UTC
This also should be one script with parameters --enable and --disable, as it is in other Koha debian commands