From a0499451a5449c76f083b43336431b7d043b425e Mon Sep 17 00:00:00 2001
From: jrandom
Date: Tue, 31 Aug 2004 21:25:23 +0000
Subject: [PATCH] let windows users install/remove the service through the
/configservice.jsp page
---
.../i2p/router/web/ConfigServiceHandler.java | 26 +++++++++++++++++--
apps/routerconsole/jsp/configservice.jsp | 15 +++++------
readme.html | 10 ++++---
3 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java
index 6bfacda4b..0d39c0465 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java
@@ -1,8 +1,9 @@
package net.i2p.router.web;
+import java.io.IOException;
+
import net.i2p.router.ClientTunnelSettings;
import net.i2p.router.Router;
-
import net.i2p.apps.systray.SysTray;
import org.tanukisoftware.wrapper.WrapperManager;
@@ -39,6 +40,10 @@ public class ConfigServiceHandler extends FormHandler {
} else if ("Hard restart".equals(_action)) {
_context.router().shutdown(Router.EXIT_HARD_RESTART);
addFormNotice("Hard restart requested");
+ } else if ("Run I2P on startup".equals(_action)) {
+ installService();
+ } else if ("Don't run I2P on startup".equals(_action)) {
+ uninstallService();
} else if ("Dump threads".equals(_action)) {
try {
WrapperManager.requestThreadDump();
@@ -74,4 +79,21 @@ public class ConfigServiceHandler extends FormHandler {
addFormNotice("Blah blah blah. whatever. I'm not going to " + _action);
}
}
-}
+
+ private void installService() {
+ try {
+ Runtime.getRuntime().exec("install_i2p_service_winnt.bat");
+ addFormNotice("Service installed");
+ } catch (IOException ioe) {
+ addFormError("Warning: unable to install the service - " + ioe.getMessage());
+ }
+ }
+ private void uninstallService() {
+ try {
+ Runtime.getRuntime().exec("uninstall_i2p_service_winnt.bat");
+ addFormNotice("Service removed");
+ } catch (IOException ioe) {
+ addFormError("Warning: unable to remove the service - " + ioe.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/routerconsole/jsp/configservice.jsp b/apps/routerconsole/jsp/configservice.jsp
index c701abdab..338e669ba 100644
--- a/apps/routerconsole/jsp/configservice.jsp
+++ b/apps/routerconsole/jsp/configservice.jsp
@@ -39,18 +39,15 @@
If you are on windows, you can either enable or disable that icon here.
-
+ <% } %>
Debugging
At times, it may be helpful to debug I2P by getting a thread dump. To do so,
please select the following option and review the thread dumped to
diff --git a/readme.html b/readme.html
index 910505967..c4bbb7e31 100644
--- a/readme.html
+++ b/readme.html
@@ -21,10 +21,12 @@ linked together).
With the I2P install we've bundled some scripts and code (from the cool folks at
tanukisoftware) to let you
-run I2P as a service on windows machines (a daemon, for you *nix geeks). To install it,
-just run install_i2p_service_winnt.bat (or install_i2p_service_unix, as root). To uninstall
-it, run uninstall_i2p_service_winnt.bat (or uninstall_i2p_service_unix, as root). To uninstall
-I2P altogether, simply wipe the I2P installation directory.
+run I2P as a service on windows machines (a daemon, for you *nix geeks). Windows users can
+add or remove the I2P service on the service control page, or
+through the install_i2p_service_winnt.bat and uninstall_i2p_service_winnt.bat scripts. *nix
+users can use the install_i2p_service_unix and uninstall_i2p_service_unix scripts included, but
+they must be run as root. To uninstall I2P altogether, simply wipe the I2P installation
+directory.