modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 58 +++++----- 1 file changed, 34 insertions(+), 24 deletions(-)
New commits: commit ff23902b5eba7b2fed45c2ec90861c53e73cc329 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jan 3 12:55:16 2011 +0100
BZ 665855 - try to find the control script file only on the OSes that actually have a chance of having it. Be more careful about FS layout assumptions...
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java index bc23c09..4582f13 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java @@ -649,21 +649,28 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone } }
- if (!found) { + //only try harder on the control script path on OSes with UNIX file system layout + if (!found && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) { 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; - } + // this is now something like /usr/sbin/httpd .. trim off the last 2 parts + int i = executablePath.lastIndexOf(File.separatorChar); + + if (i >= 0) { + executablePath = executablePath.substring(0, i); + i = executablePath.lastIndexOf(File.separatorChar); } + + if (i >= 0) { + executablePath = executablePath.substring(0, i); + for (String path : CONTROL_SCRIPT_PATHS) { + controlScriptFile = new File(executablePath, path); + if (controlScriptFile.exists()) { + found = true; + break; + } + } + } } }
commit 52447ceaa38db78686d6cd102ac51f9adf29aa0a Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jan 3 12:42:50 2011 +0100
code formatting
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java index 719d9cb..bc23c09 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java @@ -625,48 +625,51 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone File controlScriptFile = null; if (controlScriptPath != null) { controlScriptFile = resolvePathRelativeToServerRoot(controlScriptPath); - } else { - boolean found = false; - // First try server root as base - String serverRoot=null; - try { + } else { + boolean found = false; + // First try server root as base + String serverRoot = null; + try { ApacheDirectiveTree tree = loadParser(); List<ApacheDirective> directives = tree.search("/ServerRoot"); if (!directives.isEmpty()) - if (!directives.get(0).getValues().isEmpty()) - serverRoot = directives.get(0).getValues().get(0); - - }catch(Exception e){ - log.error("Could not load configuration parser.",e); - } - if (serverRoot!=null) - for (String path : CONTROL_SCRIPT_PATHS) { + if (!directives.get(0).getValues().isEmpty()) + serverRoot = directives.get(0).getValues().get(0); + + } catch (Exception e) { + log.error("Could not load configuration parser.", e); + } + if (serverRoot != null) { + for (String path : CONTROL_SCRIPT_PATHS) { controlScriptFile = new File(serverRoot, path); if (controlScriptFile.exists()) { found = true; break; } - } - 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) { + 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) { - controlScriptFile = getExecutablePath(); // fall back to the httpd binary - } + } + + if (!found) { + controlScriptFile = getExecutablePath(); // fall back to the httpd binary + } }
return controlScriptFile;
rhq-commits@lists.fedorahosted.org