Created attachment 892741 [details] /etc/init.d/tomcat patch to create CATALINA_BASE rather than CATALINA_HOME Description of problem: /etc/init.d/tomcat uses CATALINA_HOME instead of CATALINA_BASE when deciding the initd.log file location or creating a new tomcat directory. It would be safer to create a new CATALINA_BASE instance rather than a new CATALINA_HOME. It also ignores whether CATALINA_BASE has been customised in /etc/tomcat/tomcat.conf or /etc/sysconfig/$NAME. Version-Release number of selected component (if applicable): 7.0.33-4.el6 How reproducible: Always. Steps to Reproduce: 1. Create a tomcat instance as per comments in /etc/sysconfig/tomcat 2. change $CATALINA_BASE Actual results: 1. If $CATALINA_BASE does not exist, the instance will not start - the intention seems to be that the makeHomeDir should fix this, but only expects $CATALINA_HOME to have been changed, and doesn't consider $CATALINA_BASE. 2. $NAME-initrd.log file is written to $CATALINA_HOME/logs rather than $CATALINA_BASE/logs, if $TOMCAT_LOG is not set. Expected results: 1. $CATALINA_BASE is configured if it doesn't exist. 2. $NAME-initrd.log files are written to $CATALINA_BASE/logs 3. I'd suggest init script should exit with error if $CATALINA_HOME does not exist, as $CATALINA_HOME/bin (/usr/share/tomcat/bin) may be required. Additional info: 1. the init script makes the assumption that a group called $TOMCAT_USER exists, whereas the RHEL6 tomcat6 package uses a $TOMCAT_GROUP environment variable instead, which is more flexible/reliable. 2. the init script also assumes that $CATALINA_PID will not be set in /etc/tomcat/tomcat.conf or /etc/sysconfig/$NAME when fixing ownership (should happen after parseOptions). I've attached a patch that worked for me, by only creating $CATALINA_BASE if it doesn't exist, and failing if $CATALINA_HOME does not exist.
ping
anyone
Given that the CATALINA_HOME directory should be the tomcat root and the CATALINA_BASE dir should point to instance specific things (from https://tomcat.apache.org/tomcat-7.0-doc/introduction.html#Directories_and_Files), I think that the provided patch is correct and it looks good to me at first glance. I'll take a stab at incorporating it into an update and let Ivan take a look.
FWIW, the patch fixed a problem for me - I create a Tomcat instance with its own CATALINA-BASE in /etc/sysconfig/{$NAME}/ but if I tried to configure ports to the standard values of 8005/8009/8080 in server.xml (the primary instance isn't in use...), then the init script replaced them with random values, making it inconsistent with my httpd config.
I'm not sure how this went so long without being addressed, but given the length of time since the last comment I'm just going to set it closed/wontfix. If there is expressed interest in having this fix added, I can but since it's a script fix its easy to apply when needed.