Remove some redundant methods

This commit is contained in:
eyedeekay
2024-06-26 19:27:29 -04:00
parent 0fc103b777
commit 4d3e700ec3
11 changed files with 122 additions and 267 deletions

View File

@ -95,8 +95,8 @@ Windows Build
------------- -------------
After installing the dependencies and completing the preparations, After installing the dependencies and completing the preparations,
just run `make`. This will produce the install.exe - the windows just run `buildscripts/unsigned.sh`. This will produce the install.exe - the
installer, which sets up the shortcuts to launch Firefox on Windows. windows installer, which sets up the shortcuts to launch Firefox on Windows.
Building without a jpackage is no longer supported. Building without a jpackage is no longer supported.
When generating a build it's important to make sure that the When generating a build it's important to make sure that the
@ -137,7 +137,7 @@ Ubuntu in WSL.
7. Move into the i2p.firefox directory. Run the `./buildscripts/build.sh` script. 7. Move into the i2p.firefox directory. Run the `./buildscripts/build.sh` script.
cd i2p.firefox cd i2p.firefox
./buildscripts/build.sh ./buildscripts/unsigned.sh
8. Compile the NSIS installer using WSL. 8. Compile the NSIS installer using WSL.

View File

@ -48,9 +48,16 @@ export I2P_JARS="$I2P_PKG/lib"
export I2P_JBIGI="$SCRIPT_DIR/../i2p.i2p.jpackage-build/installer/lib/jbigi" export I2P_JBIGI="$SCRIPT_DIR/../i2p.i2p.jpackage-build/installer/lib/jbigi"
export I2P_JBIGI_JAR="$SCRIPT_DIR/../i2p.i2p.jpackage-build/build/jbigi.jar" export I2P_JBIGI_JAR="$SCRIPT_DIR/../i2p.i2p.jpackage-build/build/jbigi.jar"
if [ ! -d "$SCRIPT_DIR/../i2p.i2p.jpackage-build/" ]; then if [ ! -d "$SCRIPT_DIR/../i2p.i2p.jpackage-build/" ]; then
git clone --depth=1 -b "$VERSION" https://i2pgit.org/i2p-hackers/i2p.i2p "$SCRIPT_DIR/../i2p.i2p.jpackage-build/" if [ -d "$SCRIPT_DIR/../i2p.i2p/" ]; then
echo cloning from local i2p.i2p checkout
git clone --depth=1 -b "$VERSION" -l "$SCRIPT_DIR/../i2p.i2p/" "$SCRIPT_DIR/../i2p.i2p.jpackage-build/"
else
echo cloning from remote i2p.i2p repository
git clone --depth=1 -b "$VERSION" https://i2pgit.org/i2p-hackers/i2p.i2p "$SCRIPT_DIR/../i2p.i2p.jpackage-build/"
fi
fi fi
cd "$SCRIPT_DIR/../i2p.i2p.jpackage-build/" cd "$SCRIPT_DIR/../i2p.i2p.jpackage-build/"
echo "setting up git branch for build"
OLDEXTRA=$(find . -name RouterVersion.java -exec grep 'String EXTRA' {} \;) OLDEXTRA=$(find . -name RouterVersion.java -exec grep 'String EXTRA' {} \;)
if [ -z "$EXTRA" ]; then if [ -z "$EXTRA" ]; then
export EXTRACODE="win" export EXTRACODE="win"
@ -62,8 +69,7 @@ if [ "$VERSION" = master ]; then
else else
export TAG_VERSION="$VERSION" export TAG_VERSION="$VERSION"
fi fi
echo "build is: i2p-$TAG_VERSION-$VERSIONDATE-$EXTRACODE"
find . -name RouterVersion.java -exec sed -i "s|$OLDEXTRA|$EXTRA|g" {} \; find . -name RouterVersion.java -exec sed -i "s|$OLDEXTRA|$EXTRA|g" {} \;
git switch - || : git switch - || :

View File

@ -1,150 +0,0 @@
package net.i2p.router;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import net.i2p.util.Log;
public class CopyConfigDir extends I2PAppUtil {
final Log logger;
public CopyConfigDir(RouterContext ctx) {
logger = ctx.logManager().getLog(CopyConfigDir.class);
}
public 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) {
for (File file : baseDir.listFiles()) {
String fPath = file.getAbsolutePath().replace(
file.getParentFile().getAbsolutePath(), "");
String newPath = workDir.toString() + fPath;
if (file.isDirectory())
if (copyDirectory(file, new File(newPath)))
return false;
if (file.isFile())
if (0 == copyFile(file, new File(newPath), true))
return false;
}
return true;
}
public boolean copyConfigDirectory(File baseDir, File workDir) {
for (File file : baseDir.listFiles()) {
// System.out.println(file.getAbsolutePath());
String fPath = file.getAbsolutePath().replace(
file.getParentFile().getAbsolutePath(), "");
String newPath = workDir.toString() + fPath;
if (file.isDirectory())
if (!copyConfigDirectory(file, new File(newPath)))
return false;
if (file.isFile()) {
int cnr = copyFileNeverOverwrite(file, new File(newPath));
if (0 == cnr)
return false;
if (1 == cnr) {
logger.info(
"using jpackaged configs in a jpackaged install, creating jpackaged file");
File jpackagedConfigsInUse = new File(appImageHome(), "jpackaged");
if (!jpackagedConfigsInUse.exists()) {
try {
jpackagedConfigsInUse.createNewFile();
} catch (IOException e) {
logger.warn(
"Error creating jpackaged file, delete config files manually when uninstalling");
}
}
}
if (-1 == cnr) {
logger.info(
"not overwriting existing config file, not creating jpackaged file");
}
}
}
return true;
}
public int copyFileNeverOverwrite(String basePath, String workPath) {
File baseFile = new File(basePath);
File workFile = new File(workPath);
return copyFileNeverOverwrite(baseFile, workFile);
}
public int copyFileNeverOverwrite(File basePath, File workPath) {
return copyFile(basePath, workPath, false);
}
public int copyFile(File basePath, File workPath, boolean overWrite) {
if (!basePath.exists()) {
logger.info(basePath.getAbsolutePath() + " doesn't exist, not copying");
return 0;
}
if (!overWrite && workPath.exists()) {
logger.info(workPath.getAbsolutePath() +
" already exists, not overwriting");
return -1;
}
File workDir = workPath.getParentFile();
if (!workDir.exists()) {
workDir.mkdirs();
}
try (InputStream in =
new BufferedInputStream(new FileInputStream(basePath));
OutputStream out =
new BufferedOutputStream(new FileOutputStream(workPath))) {
byte[] buffer = new byte[1024];
int lengthRead;
while ((lengthRead = in.read(buffer)) > 0) {
out.write(buffer, 0, lengthRead);
out.flush();
}
in.close();
out.close();
return 1;
} catch (Throwable e) {
logger.warn(e.toString());
logger.warn("failed to copy " + basePath.getAbsolutePath() + " to " +
workPath.getAbsolutePath());
return 0;
}
}
protected boolean copyConfigDir() {
File appImageConfigDir = appImageConfig();
File appImageHomeDir = selectHome();
return copyConfigDirectory(appImageConfigDir, appImageHomeDir);
}
/**
* set up the path to the log file
*
* @return
*/
protected File logFile() { return logFile("launcher.log"); }
/**
* set up the path to the log file
*
* @return
*/
protected File logFile(String p) {
File log = new File(selectHome(), "logs");
if (!log.exists())
log.mkdirs();
return new File(log, p);
}
}

View File

@ -25,20 +25,20 @@ import net.i2p.util.Log;
* router.pid - the pid of the java process. * router.pid - the pid of the java process.
*/ */
public class WinLauncher extends I2PAppUtil { public class WinLauncher extends I2PAppUtil {
private final CopyConfigDir copyConfigDir; // private final CopyConfigDir copyConfigDir;
WinUpdatePostProcessor wupp = null; WinUpdatePostProcessor wupp = null;
private Router i2pRouter; private Router i2pRouter;
private final Log logger; private final Log logger;
public WinLauncher() { public WinLauncher() {
File programs = programFile(); File programs = programFile();
File home = homeDir();
System.setProperty( System.setProperty(
"i2p.dir.base", "i2p.dir.base",
new File(programs.getAbsolutePath(), "config").getAbsolutePath()); appImageConfig().getAbsolutePath());
System.setProperty("i2p.dir.config", home.getAbsolutePath()); System.setProperty("i2p.dir.config", appImageConfig().getAbsolutePath());
System.setProperty("router.pid", System.setProperty("router.pid",
String.valueOf(ProcessHandle.current().pid())); String.valueOf(ProcessHandle.current().pid()));
/** /**
* IMPORTANT: You must set user.dir to the same directory where the * IMPORTANT: You must set user.dir to the same directory where the
* jpackage is intstalled, or when the launcher tries to re-run itself * jpackage is intstalled, or when the launcher tries to re-run itself
@ -48,7 +48,7 @@ public class WinLauncher extends I2PAppUtil {
System.setProperty("user.dir", programs.getAbsolutePath()); System.setProperty("user.dir", programs.getAbsolutePath());
i2pRouter = new Router(routerConfig(), System.getProperties()); i2pRouter = new Router(routerConfig(), System.getProperties());
copyConfigDir = new CopyConfigDir(i2pRouter.getContext()); // copyConfigDir = new CopyConfigDir(i2pRouter.getContext());
logger = i2pRouter.getContext().logManager().getLog(WinLauncher.class); logger = i2pRouter.getContext().logManager().getLog(WinLauncher.class);
} }
@ -75,15 +75,17 @@ public class WinLauncher extends I2PAppUtil {
// This actually does most of what we use NSIS for if NSIS hasn't // This actually does most of what we use NSIS for if NSIS hasn't
// already done it, which essentially makes this whole thing portable. // already done it, which essentially makes this whole thing portable.
if (!launcher.copyConfigDir.copyConfigDir()) { /*
launcher.logger.error("Cannot copy the configuration directory"); * if (!launcher.copyConfigDir.copyConfigDir()) {
System.exit(1); * launcher.logger.error("Cannot copy the configuration directory");
} * System.exit(1);
* }
*/
if (!launcher.isInstalled("i2p")) { if (!launcher.isInstalled("i2p")) {
if (launcher.i2pRouter.saveConfig("routerconsole.browser", "NUL")) { if (launcher.i2pRouter.saveConfig("routerconsole.browser", "NUL")) {
launcher.logger.info("updated routerconsole.browser config " + launcher.logger.info("updated routerconsole.browser config " +
launcher.appImageExe()); launcher.appImageExe());
} }
} }
launcher.logger.info("Router is configured"); launcher.logger.info("Router is configured");
@ -110,25 +112,12 @@ public class WinLauncher extends I2PAppUtil {
else if (!programs.isDirectory()) { else if (!programs.isDirectory()) {
logger.warn( logger.warn(
programs + programs +
" exists but is not a directory. Please get it out of the way"); " exists but is not a directory. Please get it out of the way");
System.exit(1); System.exit(1);
} }
return programs; return programs;
} }
private File homeDir() {
File home = selectHome();
if (!home.exists())
home.mkdirs();
else if (!home.isDirectory()) {
logger.warn(
home +
" exists but is not a directory. Please get it out of the way");
System.exit(1);
}
return home;
}
// see // see
// https://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java // https://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java
private boolean isAvailable(int portNr) { private boolean isAvailable(int portNr) {
@ -152,8 +141,7 @@ public class WinLauncher extends I2PAppUtil {
sleep(1000); sleep(1000);
} }
UpdateManager um; UpdateManager um;
while ((um = (UpdateManager)cam.getRegisteredApp(UpdateManager.APP_NAME)) == while ((um = (UpdateManager) cam.getRegisteredApp(UpdateManager.APP_NAME)) == null) {
null) {
sleep(1000); sleep(1000);
} }
WinUpdatePostProcessor wupp = new WinUpdatePostProcessor(ctx); WinUpdatePostProcessor wupp = new WinUpdatePostProcessor(ctx);

View File

@ -31,12 +31,16 @@ public class WinUpdatePostProcessor implements UpdatePostProcessor {
this._log = ctx.logManager().getLog(WinUpdatePostProcessor.class); this._log = ctx.logManager().getLog(WinUpdatePostProcessor.class);
} }
public String getVersion() { return version; } public String getVersion() {
return version;
}
public File getFile() { return positionedFile; } public File getFile() {
return positionedFile;
}
public void updateDownloadedandVerified(UpdateType type, int fileType, public void updateDownloadedandVerified(UpdateType type, int fileType,
String version, File file) String version, File file)
throws IOException { throws IOException {
_log.info("Got an update to post-process"); _log.info("Got an update to post-process");
if (type != UpdateType.ROUTER_SIGNED_SU3 && if (type != UpdateType.ROUTER_SIGNED_SU3 &&
@ -97,12 +101,11 @@ public class WinUpdatePostProcessor implements UpdatePostProcessor {
private File workDir() throws IOException { private File workDir() throws IOException {
if (this.ctx != null) { if (this.ctx != null) {
File workDir = File workDir = new File(this.ctx.getConfigDir().getAbsolutePath(), "i2p_update_win");
new File(this.ctx.getConfigDir().getAbsolutePath(), "i2p_update_win");
if (workDir.exists()) { if (workDir.exists()) {
if (workDir.isFile()) if (workDir.isFile())
throw new IOException(workDir + throw new IOException(workDir +
" exists but is a file, get it out of the way"); " exists but is a file, get it out of the way");
return null; return null;
} else { } else {
workDir.mkdirs(); workDir.mkdirs();

View File

@ -14,7 +14,7 @@ class WinUpdateProcess implements Runnable {
private final Log _log; private final Log _log;
WinUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier, WinUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier,
Supplier<File> fileSupplier) { Supplier<File> fileSupplier) {
this.ctx = ctx; this.ctx = ctx;
this.versionSupplier = versionSupplier; this.versionSupplier = versionSupplier;
this.fileSupplier = fileSupplier; this.fileSupplier = fileSupplier;
@ -23,12 +23,11 @@ class WinUpdateProcess implements Runnable {
private File workDir() throws IOException { private File workDir() throws IOException {
if (ctx != null) { if (ctx != null) {
File workDir = File workDir = new File(ctx.getConfigDir().getAbsolutePath(), "i2p_update_win");
new File(ctx.getConfigDir().getAbsolutePath(), "i2p_update_win");
if (workDir.exists()) { if (workDir.exists()) {
if (workDir.isFile()) if (workDir.isFile())
throw new IOException(workDir + throw new IOException(workDir +
" exists but is a file, get it out of the way"); " exists but is a file, get it out of the way");
return workDir; return workDir;
} else { } else {
workDir.mkdirs(); workDir.mkdirs();
@ -62,13 +61,13 @@ class WinUpdateProcess implements Runnable {
try { try {
Process p = pb.directory(workingDir) Process p = pb.directory(workingDir)
.redirectErrorStream(true) .redirectErrorStream(true)
.redirectOutput(logFile) .redirectOutput(logFile)
.start(); .start();
exitCode = p.waitFor(); exitCode = p.waitFor();
if (exitCode != 0) if (exitCode != 0)
_log.error("Update failed with exit code " + exitCode + " see " + _log.error("Update failed with exit code " + exitCode + " see " +
logFile.getAbsolutePath() + " for more details"); logFile.getAbsolutePath() + " for more details");
} catch (IOException ex) { } catch (IOException ex) {
_log.error( _log.error(
"Unable to run update program in background. Update will fail.", ex); "Unable to run update program in background. Update will fail.", ex);

View File

@ -2,8 +2,15 @@ package net.i2p.router;
import java.io.File; import java.io.File;
import net.i2p.util.Log; import net.i2p.util.Log;
import net.i2p.router.RouterContext;
public class WindowsAppUtil extends WindowsServiceUtil { public class WindowsAppUtil extends WindowsServiceUtil {
private final Log _log;
public WindowsAppUtil(RouterContext ctx) {
this._log = ctx.logManager().getLog(WindowsAppUtil.class);
}
private File checkPathEnvironmentVariable(String name) { private File checkPathEnvironmentVariable(String name) {
String path_override = System.getenv(name); String path_override = System.getenv(name);
if (path_override != null) { if (path_override != null) {
@ -31,10 +38,10 @@ public class WindowsAppUtil extends WindowsServiceUtil {
* relative to the root of the app-image on each platform: * relative to the root of the app-image on each platform:
* *
* Windows - Root of appimage is 1 directory above directory named runtime * Windows - Root of appimage is 1 directory above directory named runtime
* ./runtime * ./runtime
* *
* Linux - Root of appimage is 2 directories above directory named runtime * Linux - Root of appimage is 2 directories above directory named runtime
* ./lib/runtime * ./lib/runtime
* *
* Mac OSX - Unknown for now * Mac OSX - Unknown for now
* *
@ -61,11 +68,11 @@ public class WindowsAppUtil extends WindowsServiceUtil {
File jreHome = javaHome(); File jreHome = javaHome();
if (jreHome != null) { if (jreHome != null) {
switch (osName()) { switch (osName()) {
case "windows": case "windows":
return jreHome.getAbsoluteFile().getParentFile(); return jreHome.getAbsoluteFile().getParentFile();
case "mac": case "mac":
case "linux": case "linux":
return jreHome.getAbsoluteFile().getParentFile().getParentFile(); return jreHome.getAbsoluteFile().getParentFile().getParentFile();
} }
} }
return null; return null;
@ -86,11 +93,11 @@ public class WindowsAppUtil extends WindowsServiceUtil {
// name of the executable as well // name of the executable as well
String baseName = aih.getName(); String baseName = aih.getName();
switch (osName()) { switch (osName()) {
case "windows": case "windows":
return baseName + ".exe"; return baseName + ".exe";
case "mac": case "mac":
case "linux": case "linux":
return "./bin/" + baseName; return "./bin/" + baseName;
} }
} }
return null; return null;
@ -111,21 +118,22 @@ public class WindowsAppUtil extends WindowsServiceUtil {
} }
String osName = osName(); String osName = osName();
switch (osName) { switch (osName) {
case "windows": case "windows":
File winConfigDir = new File(aih, "config"); File winConfigDir = new File(aih, "config");
if (winConfigDir != null) { if (winConfigDir != null) {
if (winConfigDir.exists()) { if (winConfigDir.exists()) {
return winConfigDir;
return winConfigDir;
}
} }
} case "mac":
case "mac": case "linux":
case "linux": File linConfigDir = new File(aih, "lib/config");
File linConfigDir = new File(aih, "lib/config"); if (linConfigDir != null) {
if (linConfigDir != null) { if (linConfigDir.exists()) {
if (linConfigDir.exists()) { return linConfigDir;
return linConfigDir; }
} }
}
} }
return null; return null;
} }

View File

@ -30,7 +30,9 @@ import javax.swing.JOptionPane;
*/ */
public class WindowsServiceUtil { public class WindowsServiceUtil {
public WindowsServiceUtil() {} public WindowsServiceUtil() {
}
public String queryService(String serviceName) { public String queryService(String serviceName) {
String result = ""; String result = "";
String line; String line;
@ -39,8 +41,7 @@ public class WindowsServiceUtil {
Process p = pb.start(); Process p = pb.start();
try { try {
p.waitFor(); // wait for process to finish then continue. p.waitFor(); // wait for process to finish then continue.
BufferedReader bri = BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = bri.readLine()) != null) { while ((line = bri.readLine()) != null) {
result += line; result += line;
} }
@ -54,6 +55,7 @@ public class WindowsServiceUtil {
} }
return result; return result;
} }
public String getStatePrefix(String qResult) { public String getStatePrefix(String qResult) {
String statePrefix = "STATE : "; String statePrefix = "STATE : ";
// get the first occurrence of "STATE", then find the // get the first occurrence of "STATE", then find the
@ -70,8 +72,9 @@ public class WindowsServiceUtil {
} }
return statePrefix; return statePrefix;
} }
public int getServiceStateInt(String serviceName) { public int getServiceStateInt(String serviceName) {
// String statePrefix = "STATE : "; // String statePrefix = "STATE : ";
String qResult = queryService(serviceName); String qResult = queryService(serviceName);
String statePrefix = getStatePrefix(qResult); String statePrefix = getStatePrefix(qResult);
// check that the temp string contains the status prefix // check that the temp string contains the status prefix
@ -79,7 +82,7 @@ public class WindowsServiceUtil {
if (ix >= 0) { if (ix >= 0) {
// compare status number to one of the states // compare status number to one of the states
String stateStr = qResult.substring(ix + statePrefix.length(), String stateStr = qResult.substring(ix + statePrefix.length(),
ix + statePrefix.length() + 1); ix + statePrefix.length() + 1);
int state = Integer.parseInt(stateStr); int state = Integer.parseInt(stateStr);
return state; return state;
} }
@ -113,15 +116,12 @@ public class WindowsServiceUtil {
if (isInstalled(serviceName)) { if (isInstalled(serviceName)) {
if (!isStart(serviceName)) { if (!isStart(serviceName)) {
int a; int a;
String message = String message = "It appears you have an existing I2P service installed.\n";
"It appears you have an existing I2P service installed.\n"; message += "However, it is not running yet. Please start it through `services.msc`.\n";
message += message += "If you click \"No\", the jpackage router will be launched instead.\n";
"However, it is not running yet. Please start it through `services.msc`.\n";
message +=
"If you click \"No\", the jpackage router will be launched instead.\n";
a = JOptionPane.showConfirmDialog(null, message, a = JOptionPane.showConfirmDialog(null, message,
"I2P Service detected not running", "I2P Service detected not running",
JOptionPane.YES_NO_OPTION); JOptionPane.YES_NO_OPTION);
if (a == JOptionPane.NO_OPTION) { if (a == JOptionPane.NO_OPTION) {
// Do nothing here, this will continue on to launch a jpackaged router // Do nothing here, this will continue on to launch a jpackaged router
return true; return true;
@ -131,8 +131,7 @@ public class WindowsServiceUtil {
// user can start the service themselves. OR maybe we ask for // user can start the service themselves. OR maybe we ask for
// elevation here? May need to refactor Elevator and Shell32X to // elevation here? May need to refactor Elevator and Shell32X to
// achieve it though // achieve it though
ProcessBuilder pb = ProcessBuilder pb = new ProcessBuilder("C:\\Windows\\System32\\services.msc");
new ProcessBuilder("C:\\Windows\\System32\\services.msc");
try { try {
Process p = pb.start(); Process p = pb.start();
int exitCode = p.waitFor(); int exitCode = p.waitFor();
@ -156,27 +155,27 @@ public class WindowsServiceUtil {
String stateString = "uninstalled"; String stateString = "uninstalled";
int state = getServiceStateInt(serviceName); int state = getServiceStateInt(serviceName);
switch (state) { switch (state) {
case (1): // service stopped case (1): // service stopped
stateString = "stopped"; stateString = "stopped";
break; break;
case (2): // service starting case (2): // service starting
stateString = "starting"; stateString = "starting";
break; break;
case (3): // service stopping case (3): // service stopping
stateString = "stopping"; stateString = "stopping";
break; break;
case (4): // service started case (4): // service started
stateString = "started"; stateString = "started";
break; break;
case (5): // service resuming from pause case (5): // service resuming from pause
stateString = "resuming"; stateString = "resuming";
break; break;
case (6): // service pausing case (6): // service pausing
stateString = "pausing"; stateString = "pausing";
break; break;
case (7): // service paused case (7): // service paused
stateString = "paused"; stateString = "paused";
break; break;
} }
return stateString; return stateString;
} }
@ -184,7 +183,7 @@ public class WindowsServiceUtil {
/** /**
* get the OS name(windows, mac, linux only) * get the OS name(windows, mac, linux only)
* *
* @return os name in lower-case, "windows" "mac" or "linux" * @return os name in lower-case, "windows" "mac" or "linux"
*/ */
protected String osName() { protected String osName() {
String osName = System.getProperty("os.name").toLowerCase(); String osName = System.getProperty("os.name").toLowerCase();
@ -194,6 +193,7 @@ public class WindowsServiceUtil {
return "mac"; return "mac";
return "linux"; return "linux";
} }
public static void main(String args[]) { public static void main(String args[]) {
WindowsServiceUtil wsu = new WindowsServiceUtil(); WindowsServiceUtil wsu = new WindowsServiceUtil();
// when querying the I2P router service installed by the IzPack installer // when querying the I2P router service installed by the IzPack installer

View File

@ -20,7 +20,7 @@ public class ZipUpdateProcess implements Runnable {
private final Log _log; private final Log _log;
ZipUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier, ZipUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier,
Supplier<File> fileSupplier) { Supplier<File> fileSupplier) {
this.ctx = ctx; this.ctx = ctx;
this.versionSupplier = versionSupplier; this.versionSupplier = versionSupplier;
this.fileSupplier = fileSupplier; this.fileSupplier = fileSupplier;
@ -29,12 +29,11 @@ public class ZipUpdateProcess implements Runnable {
private File workDir() throws IOException { private File workDir() throws IOException {
if (ctx != null) { if (ctx != null) {
File workDir = File workDir = new File(ctx.getConfigDir().getAbsolutePath(), "i2p_update_zip");
new File(ctx.getConfigDir().getAbsolutePath(), "i2p_update_zip");
if (workDir.exists()) { if (workDir.exists()) {
if (workDir.isFile()) if (workDir.isFile())
throw new IOException(workDir + throw new IOException(workDir +
" exists but is a file, get it out of the way"); " exists but is a file, get it out of the way");
return workDir; return workDir;
} else { } else {
workDir.mkdirs(); workDir.mkdirs();

View File

@ -1,3 +1,3 @@
!define VERSIONMAJOR 2 !define VERSIONMAJOR 2
!define VERSIONMINOR 5 !define VERSIONMINOR 5
!define VERSIONBUILD 1 !define VERSIONBUILD 2

View File

@ -1,8 +1,10 @@
#!/bin/bash #!/bin/bash
TORSOCKS=$(which torsocks) if [ -z "$NO_TORSOCKS" ]; then
if [ -f "${TORSOCKS}" ]; then TORSOCKS=$(which torsocks)
. "${TORSOCKS}" on if [ -f "${TORSOCKS}" ]; then
. "${TORSOCKS}" on
fi
fi fi
version="$(curl -s https://aus1.torproject.org/torbrowser/update_3/release/downloads.json | jq -r ".version")" version="$(curl -s https://aus1.torproject.org/torbrowser/update_3/release/downloads.json | jq -r ".version")"