Hardcoded paths in many support scripts

Bug #1693851 reported by Jeff Davis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Low
Unassigned
3.0
Fix Released
Low
Unassigned

Bug Description

In 2.12 and master, "/openils/bin/srfsh" is hardcoded in the following scripts in Open-ILS/src/support-scripts:

clear_expired_circ_history.srfsh
generate_fines.srfsh
hold_copy_targeter.srfsh
purge_at_events.srfsh
purge_circulations.srfsh
purge_holds.srfsh
purge_pending_users.srfsh
update_hard_due_dates.srfsh

There is an established convention for avoiding hardcoded paths here: use "BINDIR/srfsh" instead, and ensure that the correct path is inserted via sed in Open-ILS/src/Makefile.am.

In addition, "/openils/bin/oils_header.pl" is hardcoded in the following scripts:

rollover_phone_to_print.pl
set_pbx_holidays.pl

Other Perl support scripts use a relative path for oils_header.pl. We could follow that convention for these two scripts, or allow the user to optionally specify an alternate path when invoking the script, or insert the correct path during build; I'm not sure which option is preferable.

(See also bug 1255184 and bug 1662297.)

Tags: pullrequest
Revision history for this message
Jeff Davis (jdavis-sitka) wrote :

Working branch user/jeffdavis/lp1693851-support-scripts-hardcoded-paths contains two commits:

(1) A fix for the srfsh scripts, using BINDIR and substituting the correct path during build:
http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=c13436b0

(2) A fix for the Perl scripts, using a relative path for oils_header.pl:
http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=f265cb1c

Changed in evergreen:
milestone: none → 2.12.3
tags: added: pullrequest
Revision history for this message
Jason Stephenson (jstephenson) wrote :

While we're at it, a few scripts don't have paths and either need to be run directly from /openils/bin or with that in the path, which makes running them from sudo nearly impossible.

Can we fix those with this branch also, or should I open a new bug for those?

Changed in evergreen:
milestone: 2.12.3 → 2.12.4
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I tested this yesterday and received an error in the makefile

sed -i 's|BINDIR|/openils/bin|g' '/openils/bin/generate_fines.srfsh'
sed: can't read /openils/bin/generate_fines.srfsh: No such file or directory
Makefile:1010: recipe for target 'ilscore-install' failed

It looks like generate_fines.srfsh was replaced with fine_generator.pl in 2006? The commit messages mentions that the .srfsh version only has a 1mb buffer.

Open-ILS/src/Makefile.am only mentions installing fine_generator.pl, and the crontab examples use fine_generator.pl.

Should I start a bug for removing generate_fines.srfsh?
Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I did a little more looking and neither of these scripts are installed during the install, I think they have both been superseded.

generate_fines.srfsh
hold_copy_targeter.srfsh

I don't think those should be included in your patch for the srfsh scripts.

Neither of the perl scripts you included are included in the install either. Also, the oils_header.pl script isn't included in the install, I just checked our system and found that there were updates for oils_header.pl from Nov 2015 that we are not using because the install process doesn't update it. Bug 741788 mentions that oils_header.pl needs to be installed during make install.

And it seems to me that making the path relative causes the problem that Jason mentions, about needing /openils/bin in the path for the script to run, which makes using sudo hard for those scripts. I think that converting those over to the BINDIR substitution would work better, but only after/when they are included in the install.

The rollover_phone_to_print.pl requires config info be set in the script, so just overwriting it on install is problematic right now. I needs a config file or it should use opensrf.xml to store it's settings.

So here is a branch that only includes the srfsh scripts that are included in the install, and doesn't include the perl script commit. I think this will work without errors now.
http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/stompro/lp1693851-support-scripts-hardcoded-paths

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

It looks like Galens working branch for installing the marc stream importer includes a fix for the relative path issue in perl scripts using FindBin.

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/gmcharlt/lp741788_wip

-require 'oils_header.pl';
+use FindBin;
+require "$FindBin::Bin/oils_header.pl";

Josh

Changed in evergreen:
milestone: 2.12.4 → 2.12.5
Revision history for this message
Galen Charlton (gmc) wrote :

I've pushed the patch with Josh's signoff that touches only the srfsh scripts to master and rel_2_12. Thanks, Jeff and Josh!

I'll open a new bug for the remaining Perl files.

Changed in evergreen:
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Galen Charlton (gmc) wrote :

And that bug is bug 1709160

Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.