update the configuration file to point back automatically
This commit is contained in:
@@ -232,6 +232,28 @@ public class CopyConfigDir {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the path to the binary of the app-image root by getting the path to
|
||||||
|
* java.home and the OS, and traversing up to the app-image root based on that
|
||||||
|
* information, then getting the binary path on a per-platform basis. The path
|
||||||
|
* returned will be relative to the root.
|
||||||
|
*
|
||||||
|
* @return the app-image root
|
||||||
|
*/
|
||||||
|
protected static String appImageExe() {
|
||||||
|
File aih = appImageHome();
|
||||||
|
if (aih != null) {
|
||||||
|
switch (osName()) {
|
||||||
|
case "windows":
|
||||||
|
return "I2P.exe";
|
||||||
|
case "mac":
|
||||||
|
case "linux":
|
||||||
|
return "./bin/I2P";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the path to the default config of the app-image by getting the path to
|
* 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
|
* java.home and the OS, and traversing up to the app-image root based on that
|
||||||
@@ -272,6 +294,17 @@ public class CopyConfigDir {
|
|||||||
return copyConfigDirectory(appImageConfigDir, appImageHomeDir);
|
return copyConfigDirectory(appImageConfigDir, appImageHomeDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static String routerConfig() {
|
||||||
|
File appImageHomeDir = appImageHome();
|
||||||
|
File routerConf = new File(appImageHomeDir, "router.config");
|
||||||
|
if (routerConf != null) {
|
||||||
|
if (routerConf.exists()) {
|
||||||
|
return routerConf.getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set up the path to the log file
|
* set up the path to the log file
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -94,11 +94,6 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launchBrowser(privateBrowsing, usabilityMode, chromiumFirst,
|
|
||||||
proxyTimeoutTime, newArgsList)) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.setProperty("i2p.dir.base", programs.getAbsolutePath());
|
System.setProperty("i2p.dir.base", programs.getAbsolutePath());
|
||||||
System.setProperty("i2p.dir.config", home.getAbsolutePath());
|
System.setProperty("i2p.dir.config", home.getAbsolutePath());
|
||||||
System.setProperty("router.pid",
|
System.setProperty("router.pid",
|
||||||
@@ -115,7 +110,18 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
*/
|
*/
|
||||||
System.setProperty("user.dir", programs.getAbsolutePath());
|
System.setProperty("user.dir", programs.getAbsolutePath());
|
||||||
|
|
||||||
i2pRouter = new Router(System.getProperties());
|
i2pRouter = new Router(routerConfig(), System.getProperties());
|
||||||
|
|
||||||
|
if (i2pRouter.saveConfig("routerconsole.browser", null)) {
|
||||||
|
logger.info("removed routerconsole.browser config");
|
||||||
|
}
|
||||||
|
if (i2pRouter.saveConfig("routerconsole.browser", appImageExe())) {
|
||||||
|
logger.info("updated routerconsole.browser config " + appImageExe());
|
||||||
|
}
|
||||||
|
if (launchBrowser(privateBrowsing, usabilityMode, chromiumFirst,
|
||||||
|
proxyTimeoutTime, newArgsList)) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
logger.info("Router is configured");
|
logger.info("Router is configured");
|
||||||
|
|
||||||
Thread registrationThread = new Thread(REGISTER_UPP);
|
Thread registrationThread = new Thread(REGISTER_UPP);
|
||||||
@@ -129,20 +135,6 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setupLauncher() {
|
private static void setupLauncher() {
|
||||||
try {
|
|
||||||
// This block configure the logger with handler and formatter
|
|
||||||
fh = new FileHandler(logFile().toString());
|
|
||||||
logger.addHandler(fh);
|
|
||||||
SimpleFormatter formatter = new SimpleFormatter();
|
|
||||||
fh.setFormatter(formatter);
|
|
||||||
// the following statement is used to log any messages
|
|
||||||
logger.info("My first log");
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
File jrehome = javaHome();
|
File jrehome = javaHome();
|
||||||
logger.info("jre home is: " + jrehome.getAbsolutePath());
|
logger.info("jre home is: " + jrehome.getAbsolutePath());
|
||||||
File appimagehome = appImageHome();
|
File appimagehome = appImageHome();
|
||||||
|
|||||||
Reference in New Issue
Block a user