<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [3311] RHQ-625 Try harder to detect the apachectl binary, as the previous code did fail on RHEL 5, as RHEL has a special directory layout.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3311</dd> <dt>Author</dt> <dd>hrupp</dd> <dt>Date</dt> <dd>2009-03-05 15:34:25 -0600 (Thu, 05 Mar 2009)</dd> </dl> <h3>Log Message</h3> <pre>RHQ-625 Try harder to detect the apachectl binary, as the previous code did fail on RHEL 5, as RHEL has a special directory layout.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulespluginsapachesrcmainjavaorgrhqpluginsapacheApacheServerComponentjava">rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulespluginsapachesrcmainjavaorgrhqpluginsapacheApacheServerComponentjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java (3310 => 3311)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java 2009-03-05 21:03:05 UTC (rev 3310) +++ rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java 2009-03-05 21:34:25 UTC (rev 3311) </span><span class="lines">@@ -92,6 +92,8 @@ </span><span class="cx"> private static final String ERROR_LOG_ENTRY_EVENT_TYPE = "errorLogEntry"; </span><span class="add">+ private static final String[] CONTROL_SCRIPT_PATHS = {"bin/apachectl", "sbin/apachectl", "bin/apachectl2", "sbin/apachectl2" }; + </span><span class="cx"> private ResourceContext resourceContext; private EventContext eventContext; private SNMPClient snmpClient; </span><span class="lines">@@ -334,7 +336,7 @@ </span><span class="cx"> /** * Returns the httpd.conf file </span><span class="rem">- * @return A File object that represents the httpd.conf file or null in case of error </span><span class="add">+ * @return A File object that represents the httpd.conf file or null in case of error </span><span class="cx"> */ public File getHttpdConfFile() { Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); </span><span class="lines">@@ -348,6 +350,9 @@ </span><span class="cx"> * Return the absolute path of this Apache server's control script (e.g. "C:\Program Files\Apache * Group\Apache2\bin\Apache.exe"). * </span><span class="add">+ * On Unix we need to try various locations, as some unixes have bin/ conf/ .. all within one root + * and on others those are separated. + * </span><span class="cx"> * @return the absolute path of this Apache server's control script (e.g. "C:\Program Files\Apache * Group\Apache2\bin\Apache.exe") */ </span><span class="lines">@@ -355,20 +360,42 @@ </span><span class="cx"> public File getControlScriptPath() { Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); String controlScriptPath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH, null); </span><span class="rem">- File controlScriptFile; </span><span class="add">+ File controlScriptFile = null; </span><span class="cx"> if (controlScriptPath != null) { controlScriptFile = resolvePathRelativeToServerRoot(controlScriptPath); } else { SystemInfo systemInfo = this.resourceContext.getSystemInformation(); if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX { </span><span class="add">+ boolean found = false; + // First try server root as base </span><span class="cx"> String serverRoot = getRequiredPropertyValue(pluginConfig, PLUGIN_CONFIG_PROP_SERVER_ROOT); </span><span class="rem">- // Try different possibilities, as even on apache2 this is not always apache2ctl - controlScriptFile = new File(serverRoot, "bin/apachectl"); - if (!controlScriptFile.exists()) { - controlScriptFile = new File(serverRoot, "bin/apache2ctl"); </span><span class="add">+ + for (String path : CONTROL_SCRIPT_PATHS) { + controlScriptFile = new File(serverRoot, path); + if (controlScriptFile.exists()) { + found = true; + break; + } </span><span class="cx"> } </span><span class="rem">- if (!controlScriptFile.exists()) { </span><span class="add">+ if (!found) { + String executablePath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, null); + if (executablePath!=null) { + // this is now somethig like /usr/sbin/httpd .. trim off the last 2 parts + int i = executablePath.lastIndexOf('/'); + executablePath = executablePath.substring(0,i); + i = executablePath.lastIndexOf('/'); + executablePath = executablePath.substring(0,i); + for (String path : CONTROL_SCRIPT_PATHS) { + controlScriptFile = new File(executablePath, path); + if (controlScriptFile.exists()) { + found = true; + break; + } + } + } + } + if (!found) { </span><span class="cx"> controlScriptFile = getExecutablePath(); // fall back to the httpd binary } } else // Windows </span> </pre> </div> </div> </body> </html> |