Bug 31055 - Move koha-functions to /usr/sbin instead of koha/bin
Summary: Move koha-functions to /usr/sbin instead of koha/bin
Status: CLOSED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-27 13:00 UTC by Marcel de Rooy
Modified: 2023-06-08 22:26 UTC (History)
3 users (show)

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


Attachments
Bug 31055: Update install location for koha-functions (1.85 KB, patch)
2022-06-27 13:14 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31055: Change the source statement in koha scripts (18.23 KB, patch)
2022-06-27 13:14 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2022-06-27 13:00:19 UTC
For a long time I am copying koha-functions.sh to /usr/share/koha/bin, since that is the location that the koha-* scripts expect it to be.
It would be easier to put it in sbin too.

Please tell me if there are valid legitimate reasons to do not so.
Comment 1 Marcel de Rooy 2022-06-27 13:00:56 UTC
(In reply to Marcel de Rooy from comment #0)
> For a long time I am copying koha-functions.sh to /usr/share/koha/bin, since
> that is the location that the koha-* scripts expect it to be.

Talking about a gitified dev package install.
Comment 2 Marcel de Rooy 2022-06-27 13:14:10 UTC
Created attachment 136580 [details] [review]
Bug 31055: Update install location for koha-functions

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2022-06-27 13:14:14 UTC
Created attachment 136581 [details] [review]
Bug 31055: Change the source statement in koha scripts

All references to koha-functions moved to sbin.

git grep -l "bin/koha-functions.sh" | xargs sed -i -e's/usr\/share\/koha\/bin\/koha-functions.sh/usr\/sbin\/koha-functions.sh/g'

Test plan:
[1] Copy debian scripts to /usr/sbin locally.
[2] Remove /usr/share/koha/bin/koha-functions.sh
[3] Try a few scripts
[4] git grep -E "[^s]bin/koha-funct". No occurrences?

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 David Cook 2022-06-27 23:49:42 UTC
(In reply to Marcel de Rooy from comment #0)
> For a long time I am copying koha-functions.sh to /usr/share/koha/bin, since
> that is the location that the koha-* scripts expect it to be.
> It would be easier to put it in sbin too.
> 
> Please tell me if there are valid legitimate reasons to do not so.

Well, koha-functions.sh isn't a command/executable that should be in the $PATH, so really it shouldn't be in /usr/sbin (or /usr/share/koha/bin really).

koha-functions.sh should probably be in /usr/lib/koha or /usr/share/koha/lib I suppose.

For example:
/usr/lib/lsb/init-functions
/usr/lib/cryptsetup/functions
Comment 5 Marcel de Rooy 2022-06-28 11:26:24 UTC
(In reply to David Cook from comment #4)
> Well, koha-functions.sh isn't a command/executable that should be in the
> $PATH, so really it shouldn't be in /usr/sbin (or /usr/share/koha/bin
> really).
> 
> koha-functions.sh should probably be in /usr/lib/koha or /usr/share/koha/lib
> I suppose.

Thx David. Yes, you are quite right about that.
Pragmatically, I would not mind pushing it along with the real scripts though.

And cheatingly we could add some kind of help/usage statement to it, making it a real script too :)
The fact that we are storing it in debian/scripts, gave it the .sh extension and copy it to koha/bin does not help either..
Comment 6 Marcel de Rooy 2022-07-08 06:12:22 UTC
It seems that no one is interested in this change.
I will no longer spend time on it.
Comment 7 Tomás Cohen Arazi 2022-07-16 15:01:21 UTC
Hi all.
Comment 8 Tomás Cohen Arazi 2022-07-16 15:01:44 UTC
wajasu was asking for this. Re-opening to keep the discussion flowing.
Comment 9 David Cook 2022-07-17 23:55:11 UTC
I suppose it depends on how pedantic we want to be. 

But I think Marcel has a good point. It probably makes more sense to use "/usr/sbin" than "/usr/share/koha/bin" since that's where the other koha-* shell code is. 

Even if someone did run "koha-functions.sh" via $PATH, it wouldn't actually do anything. 

(Alternatively, we could always have a "/usr/share/koha/bin/scripts" and symlink the /usr/sbin/koha-* stuff to the code in that location. Plus potentially update koha-gitify to symlink /usr/sbin/koha-* stuff as well - at least on Debian/Ubuntu. )
Comment 10 wajasu 2022-07-19 14:47:21 UTC
if you colocate the koha-functions.sh next to the other scripts, you can source them path relative. But if other scripts somewhere else them, they will use have an absolute path.

Some lib or scripts directory is definitely desired with an absolute path.

Will they be used by maintenance scripts?  That you probably don't want in /usr/sbin.
I didn't find any currently when grepping. Most of our scripts are perl, but these are bash shell.

A) /usr/share/koha/lib           <-- perl code
B) /usr/share/koha/lib/scripts   <-- doesn't exist yet
C) /usr/sbin                     <-- but gets out commands available in system dir
D) /usr/share/koha/bin           <-- This is where koha-functions.sh is now.
                                  (which not on the PATH in KTD.  by design?)

I can easily test many of the koha-functions by sourcing the file from debian/scripts and just calling them in the shell to examine $? and such.

Then I just run the cp_debian_files.pl everytime I make change.  Because the koha-commands are sourcing the absolute path anyway.  A pain to fix/test, but it works.

I tried to add a PREPATH inthe files/templates/defaults.env and change it in my .env, but alas run.sh is set in stone in the image.  Making it less easy to change (accidentall).
I was trying to put /kohadevbox/koha/debian/scripts prepended to the PATH so I could edit/test without cp_debian_files.pl but that would only work if run.sh had PATH=${PREPATH}:/usr/bin/usr/sbin/${PATH}:/kohadevbox/bin  and the koha-* scripts used source ./koha-functions.sh

Maybe making it less painful to test with koha_functions.sh in the same directory as /usr/sbin  is less clunky to fix/test and even explain an easier test plan (without cp_debian_files.pl).
Comment 11 Marcel de Rooy 2022-09-09 07:20:32 UTC
What is the conclusion of our discussion ? :)
Comment 12 Marcel de Rooy 2022-09-22 08:49:38 UTC
Closing this one (again)