make jinetd relocatable
[org.ibex.jinetd.git] / src / org / ibex / jinetd / Root.java
index b844c9b..6b5467d 100644 (file)
@@ -6,6 +6,7 @@ import java.net.*;
 
 public class Root extends Loader {
 
+    public static String root = System.getProperty("jinetd.root", "/jinetd");
     private final Host host;
     private final Watched port;
 
@@ -32,7 +33,7 @@ public class Root extends Loader {
             Log.warn(this, "/host changed");
         } else if (w.part.equals("port")) {
             Log.warn(this, "/port changed");
-        } else if (w.getAbsolutePath().startsWith("/jinetd/LIB/")) {
+        } else if (w.getAbsolutePath().startsWith(Root.root + "/LIB/")) {
             if (w.lastModifiedAtLastScan != -1) {
                 Log.error(this, "jinetd upgraded; bouncing the JVM....");
                 reboot();
@@ -49,7 +50,7 @@ public class Root extends Loader {
             String portnum = part.indexOf(':') == -1 ? part : part.substring(part.indexOf(':') + 1);
             try {
                 return new Port(this.path + File.separatorChar + part,
-                                ipaddr == null ? null : NetworkInterface.getByInetAddress(InetAddress.getByName(ipaddr)),
+                                ipaddr == null ? null : InetAddress.getByName(ipaddr),
                                 portnum.equals("*") ? 0 : Integer.parseInt(portnum));
             } catch (UnknownHostException e) {  Log.warn(this, "can't resolve host for port directory: " + part);
             } catch (NumberFormatException e) { Log.warn(this, "invalid port directory: " + part);