FELIX-1516: Child instances use stuff from the /etc directory in the root

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@807374 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
index 59c05e6..bbda543 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
@@ -52,7 +52,11 @@
 
     private static void updateClassLoader() throws Exception {
         File home = Utils.getKarafHome();
-        File file = new File(new File(home, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
+        File base = Utils.getKarafBase(home);
+        File file = new File(new File(base, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
+        if (!file.exists()) {
+            file = new File(new File(home, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
+        }
         if (!file.exists()) {
             throw new FileNotFoundException(file.getAbsolutePath());
         }
@@ -69,7 +73,10 @@
         if (bundle == null) {
             throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework + " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
         }
-        File bundleFile = new File(home, bundle);
+        File bundleFile = new File(base, bundle);
+        if (!bundleFile.exists()) {
+            bundleFile = new File(home, bundle);
+        }
         if (!bundleFile.exists()) {
             throw new FileNotFoundException(bundleFile.getAbsolutePath());
         }
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
index a760cac..275a405 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
@@ -144,7 +144,7 @@
 
     public void launch() throws Exception {
         karafHome = Utils.getKarafHome();
-        karafBase = getKarafBase(karafHome);
+        karafBase = Utils.getKarafBase(karafHome);
 
         //System.out.println("Karaf Home: "+main.servicemixHome.getPath());
         //System.out.println("Karaf Base: "+main.servicemixBase.getPath());
@@ -300,27 +300,6 @@
         }
     }
 
-    private static File getKarafBase(File defaultValue) {
-        File rc = null;
-
-        String path = System.getProperty(PROP_KARAF_BASE);
-        if (path != null) {
-            rc = Utils.validateDirectoryExists(path, "Invalid " + PROP_KARAF_BASE + " system property");
-        }
-
-        if (rc == null) {
-            path = System.getenv(ENV_KARAF_BASE);
-            if (path != null) {
-                rc = Utils.validateDirectoryExists(path, "Invalid " + ENV_KARAF_BASE + " environment variable");
-            }
-        }
-
-        if (rc == null) {
-            rc = defaultValue;
-        }
-        return rc;
-    }
-
     private static void processSecurityProperties(Properties m_configProps) {
         String prop = m_configProps.getProperty("org.apache.felix.karaf.security.providers");
         if (prop != null) {
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java
index db8fad7..61c03ee 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java
@@ -90,4 +90,25 @@
         }
         return rc;
     }
+
+    public static File getKarafBase(File defaultValue) {
+        File rc = null;
+
+        String path = System.getProperty(Main.PROP_KARAF_BASE);
+        if (path != null) {
+            rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_BASE + " system property");
+        }
+
+        if (rc == null) {
+            path = System.getenv(Main.ENV_KARAF_BASE);
+            if (path != null) {
+                rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_BASE + " environment variable");
+            }
+        }
+
+        if (rc == null) {
+            rc = defaultValue;
+        }
+        return rc;
+    }
 }