[rhq] Branch 'release-3.0.0' - 2 commits - modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 58 +++++-----
1 file changed, 34 insertions(+), 24 deletions(-)
New commits:
commit c334fb6df2401e9927cd75cdc765dd6e6a4c3ae4
Author: Lukas Krejci <lkrejci(a)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 fa40c14..b320028 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
@@ -657,21 +657,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 0f4fe0b4e5fbed66ce304ca227550606a313fd99
Author: Lukas Krejci <lkrejci(a)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 95b8a54..fa40c14 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
@@ -633,48 +633,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;
13 years, 4 months