diff --git a/build.sh b/build.sh index cc6d20e..d466289 100755 --- a/build.sh +++ b/build.sh @@ -72,6 +72,7 @@ fi cd java "$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/i2pfirefox.jar:$HERE/build/jna.jar":"$HERE/build/jna-platform.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ + net/i2p/router/CopyConfigDir.java \ net/i2p/router/Elevator.java \ net/i2p/router/Shell32X.java \ net/i2p/router/WinLauncher.java \ diff --git a/java/net/i2p/router/CopyConfigDir.java b/java/net/i2p/router/CopyConfigDir.java index 7e11ad5..984baf0 100644 --- a/java/net/i2p/router/CopyConfigDir.java +++ b/java/net/i2p/router/CopyConfigDir.java @@ -10,13 +10,13 @@ import java.io.OutputStream; public class CopyConfigDir { - public boolean copyDirectory(String baseDir, String workDir) { + public static boolean copyDirectory(String baseDir, String workDir) { File baseFile = new File(baseDir); File workFile = new File(workDir); return copyDirectory(baseFile, workFile); } - - public boolean copyDirectory(File baseDir, File workDir) { + + public static boolean copyDirectory(File baseDir, File workDir) { for (File file : baseDir.listFiles()) { System.out.println(file.getAbsolutePath()); if (file.isDirectory()) @@ -27,7 +27,7 @@ public class CopyConfigDir { return true; } - public boolean copyConfigDirectory(File baseDir, File workDir) { + public static boolean copyConfigDirectory(File baseDir, File workDir) { for (File file : baseDir.listFiles()) { System.out.println(file.getAbsolutePath()); if (file.isDirectory()) @@ -38,17 +38,17 @@ public class CopyConfigDir { return true; } - public boolean copyFileNeverOverwrite(String basePath, String workPath) { + public static boolean copyFileNeverOverwrite(String basePath, String workPath) { File baseFile = new File(basePath); File workFile = new File(workPath); return copyFileNeverOverwrite(baseFile, workFile); } - public boolean copyFileNeverOverwrite(File basePath, File workPath) { + public static boolean copyFileNeverOverwrite(File basePath, File workPath) { return copyFile(basePath, workPath, false); } - public boolean copyFile(File basePath, File workPath, boolean overWrite) { + public static boolean copyFile(File basePath, File workPath, boolean overWrite) { if (!basePath.exists()) { return false; } diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index b740acf..c6614b9 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -30,7 +30,7 @@ import net.i2p.util.SystemVersion; * appdata * router.pid - the pid of the java process. */ -public class WinLauncher { +public class WinLauncher extends CopyConfigDir { static Logger logger = Logger.getLogger("launcherlog"); static WindowsUpdatePostProcessor wupp = null; static FileHandler fh; @@ -100,6 +100,10 @@ public class WinLauncher { // but probably ceases to be necessary, I can make jpackage generate // the installer, **and** I get to build every other kind of jpackage // powered package. + if (!copyConfigDir()){ + logger.severe("Cannot copy the configuration directory"); + System.exit(1); + } if (launchBrowser(privateBrowsing, usabilityMode, chromiumFirst, proxyTimeoutTime, newArgsList)) { @@ -113,6 +117,7 @@ public class WinLauncher { logger.info("\t" + System.getProperty("i2p.dir.base") + "\n\t" + System.getProperty("i2p.dir.config") + "\n\t" + System.getProperty("router.pid")); + /** * IMPORTANT: You must set user.dir to the same directory where the * jpackage is intstalled, or when the launcher tries to re-run itself @@ -130,13 +135,8 @@ public class WinLauncher { registrationThread.start(); setNotStarting(); - // TODO: I actually did this once before, and reversed it for - // some dumb reason I can't remember. But if I go back through - // all the steps then I set up the router before I run it ^^ - // see above commented out `wupp` and I don't have to wait for - // certain contexts to be ready anymore. + i2pRouter.runRouter(); - // RouterLaunch.main(args); } private static void setupLauncher() { @@ -437,7 +437,8 @@ public class WinLauncher { /** * get the path to the default config of the app-image by getting the path to * java.home and the OS, and traversing up to the app-image root based on that - * information, then appending lib/config to the end. + * information, then appending the config directory to the end onn a + * per-platform basis * * @return the app-image root */ @@ -467,6 +468,12 @@ public class WinLauncher { return null; } + private static boolean copyConfigDir() { + File appImageConfigDir = appImageConfig(); + File appImageHomeDir = appImageHome(); + return copyDirectory(appImageConfigDir, appImageHomeDir); + } + /** * set up the path to the log file *