diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java index 0bf04dc134dbc38a6f5e321669da6dfcd7dedf45..0b71b52de0ed728276786320208137ee5550f940 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java @@ -84,13 +84,19 @@ public class PluginStarter implements Runnable { if (server != null) { File consoleDir = new File(pluginDir, "console"); Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath()); - File webappDir = new File(pluginDir, "webapps"); + File webappDir = new File(consoleDir, "webapps"); String fileNames[] = webappDir.list(RouterConsoleRunner.WarFilenameFilter.instance()); if (fileNames != null) { for (int i = 0; i < fileNames.length; i++) { try { String warName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war")); - // check for duplicates in $I2P ? + // check for duplicates in $I2P + // easy way for now... + if (warName.equals("i2psnark") || warName.equals("susidns") || warName.equals("i2ptunnel") || + warName.equals("susimail") || warName.equals("addressbook")) { + log.error("Skipping duplicate webapp " + warName + " in plugin " + appName); + continue; + } String enabled = props.getProperty(PREFIX + warName + ENABLED); if (! "false".equals(enabled)) { String path = new File(webappDir, fileNames[i]).getCanonicalPath(); @@ -161,6 +167,24 @@ public class PluginStarter implements Runnable { } // stop console webapps in console/webapps + Server server = getConsoleServer(); + if (server != null) { + File consoleDir = new File(pluginDir, "console"); + Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath()); + File webappDir = new File(consoleDir, "webapps"); + String fileNames[] = webappDir.list(RouterConsoleRunner.WarFilenameFilter.instance()); + if (fileNames != null) { + for (int i = 0; i < fileNames.length; i++) { + String warName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war")); + if (warName.equals("i2psnark") || warName.equals("susidns") || warName.equals("i2ptunnel") || + warName.equals("susimail") || warName.equals("addressbook")) { + continue; + } + WebAppStarter.stopWebApp(server, warName); + } + } + } + // remove summary bar link Properties props = pluginProperties(ctx, appName); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java index dafc1c10a5194c02165cf602f31fbcd518af87bb..3e24a38c41a6068bfeafc2268bca826f6f7dab04 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java @@ -7,6 +7,7 @@ import java.util.StringTokenizer; import net.i2p.I2PAppContext; +import org.mortbay.http.HttpContext; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.WebApplicationContext; @@ -57,4 +58,17 @@ public class WebAppStarter { wac.setConfigurationClassNames(newClassNames); return wac; } + + /** + * stop it + */ + static void stopWebApp(Server server, String appName) { + // this will return a new context if one does not exist + HttpContext wac = server.getContext('/' + appName); + try { + // false -> not graceful + wac.stop(false); + } catch (InterruptedException ie) {} + } + }