Bug 195826 - Patch to textproc/apache-solr rc.d startup script to allow Solr to run on a given host and port (and as a given user)
Summary: Patch to textproc/apache-solr rc.d startup script to allow Solr to run on a g...
Status: Closed DUPLICATE of bug 197377
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
: 195827 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-09 15:56 UTC by Paul Mather
Modified: 2015-02-16 06:08 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (gaod)


Attachments
Patch against /usr/ports/textproc/apache-solr/files/solr.in (856 bytes, patch)
2015-02-06 17:06 UTC, Paul Mather
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Mather 2014-12-09 15:56:34 UTC
The rc.d solr startup script for textproc/apache-solr currently only allows Solr to run as root and Solr itself will bind to all available interfaces when it runs.  It is desirable to run network daemons so they will bind to a particular interface (e.g., to coexist better with Jails), and also to run as a particular user.  To that end, I've modified the /usr/local/etc/rc.d/solr startup script so that Solr can at least be bound to a particular host and port.

I've also almost achieved the latter aim of allowing Solr to be run as a non-root user.  The only thing preventing the startup script being able to do this is that is needs to ensure the /usr/local/share/examples/apache-solr/solr-webapp directory is writable by the user under which Solr is to be run.  (The solr-webapp directory is the one into which the bundled Jetty deploys Solr.)

There are two other changes to the solr rc.d script that support being able to run Solr as an unprivileged user: specifying the location of the logs and pid file.  (Both currently specify locations requiring root write access.)

The changes in the patch below support the following rc.conf settings for the solr rc.d script:

solr_host: IP address to bind to (defaults to 0.0.0.0, i.e., all interfaces)
solr_port: port to bind to (defaults to 8983)
solr_log: directory to store log files (defaults to /var/log)
solr_pidfile: location of pidfile (defaults to /var/run/solr.pid)

All the defaults default to the current behaviour of the port.  If solr_user is set in /etc/rc.conf, and the solr-webapp exists and is writable by that user, then Solr will run successfully as $solr_user, assuming solr_log and solr_pidfile point to places writable by that user.

Here is the patch to textproc/apache-solr:

--- /usr/local/etc/rc.d/solr	2014-12-08 17:47:24.509744000 -0500
+++ solr	2014-12-09 10:34:32.154587847 -0500
@@ -38,13 +38,17 @@
 
 : ${solr_enable:=NO}
 : ${solr_instance:=/var/db/solr}
+: ${solr_pidfile:=/var/run/solr.pid}
+: ${solr_log:=/var/log}
+: ${solr_host:=0.0.0.0}
+: ${solr_port:=8983}
 
 required_files=${solr_instance}/solr.xml
-pidfile=/var/run/solr.pid
+pidfile=${solr_pidfile}
 command=/usr/sbin/daemon
 procname=/usr/local/openjdk7/bin/java
 start_precmd="cd /usr/local/share/examples/apache-solr"
 
-command_args="-f -p ${pidfile} ${procname} ${solr_flags} -Dsolr.solr.home=${solr_instance} -Dsolr.log=/var/log -jar /usr/local/share/examples/apache-solr/start.jar"
+command_args="-f -p ${pidfile} ${procname} ${solr_flags} -Djetty.host=${solr_host} -Djetty.port=${solr_port} -Dsolr.solr.home=${solr_instance} -Dsolr.log=${solr_log} -jar /usr/local/share/examples/apache-solr/start.jar"
 
 run_rc_command "$1"
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2014-12-09 15:56:34 UTC
Maintainer CC'd
Comment 2 John Marino freebsd_committer freebsd_triage 2014-12-09 16:07:03 UTC
*** Bug 195827 has been marked as a duplicate of this bug. ***
Comment 3 John Marino freebsd_committer freebsd_triage 2015-02-06 16:30:44 UTC
paul, 
The maintainer has not responded in his allotted time (two weeks).
However, you also didn't provide the patch as an attachment which is a requirement.  (most people aren't going to cut and paste a patch from a browser).

Please update the PR by attaching a patch and we can promote it without maintainer approval.
Comment 4 John Marino freebsd_committer freebsd_triage 2015-02-06 16:59:54 UTC
fyi - this port no longer has a maintainer as of 30 seconds ago.
Comment 5 Hung-Yi Chen 2015-02-06 17:03:41 UTC
I'm sorry for the late reply.

I've created another pr #197377 which contain this one.
Comment 6 Paul Mather 2015-02-06 17:06:18 UTC
Created attachment 152626 [details]
Patch against /usr/ports/textproc/apache-solr/files/solr.in
Comment 7 Paul Mather 2015-02-06 17:08:13 UTC
Sorry for not including a separate patch last time: I'm not familiar with PR submission etiquette.  I've attached a new patch that is against the /usr/ports/textproc/apache-solr/files/solr.in file, to make it easier to update the port with my suggested change.
Comment 8 Kubilay Kocak freebsd_committer freebsd_triage 2015-02-16 06:08:03 UTC
Superseded by bug 197377

*** This bug has been marked as a duplicate of bug 197377 ***