Adds the ability to use $OS and $ARCH variables in clients.config and plugins.config(updateURL.* only)

This commit is contained in:
idk
2022-02-02 18:57:30 +00:00
parent b4e2366458
commit 73e34b3941
3 changed files with 67 additions and 3 deletions

View File

@@ -9,6 +9,8 @@ import java.util.Properties;
import net.i2p.router.RouterContext;
import net.i2p.router.web.PluginStarter;
import net.i2p.update.*;
import net.i2p.util.Log;
import net.i2p.util.SystemVersion;
/**
* Check for or download an updated version of a plugin.
@@ -27,12 +29,14 @@ import net.i2p.update.*;
class PluginUpdateHandler implements Checker, Updater {
private final RouterContext _context;
private final ConsoleUpdateManager _mgr;
private final Log _log;
public PluginUpdateHandler(RouterContext ctx, ConsoleUpdateManager mgr) {
_context = ctx;
_log = _context.logManager().getLog(PluginUpdateHandler.class);
_mgr = mgr;
}
/** check a single plugin */
@Override
public UpdateTask check(UpdateType type, UpdateMethod method,
@@ -48,6 +52,10 @@ class PluginUpdateHandler implements Checker, Updater {
xpi2pURL = props.getProperty("updateURL");
List<URI> updateSources = null;
if (xpi2pURL != null) {
xpi2pURL = xpi2pURL.replace("$OS", SystemVersion.getOS());
xpi2pURL = xpi2pURL.replace("$ARCH", SystemVersion.getArch());
if (_log.shouldLog(Log.INFO))
_log.info("Checking for updates for " + appName + ": " + xpi2pURL);
try {
updateSources = Collections.singletonList(new URI(xpi2pURL));
} catch (URISyntaxException use) {}
@@ -61,7 +69,7 @@ class PluginUpdateHandler implements Checker, Updater {
UpdateRunner update = new PluginUpdateChecker(_context, _mgr, updateSources, appName, oldVersion);
return update;
}
/** download a single plugin */
@Override
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
@@ -83,4 +91,4 @@ class PluginUpdateHandler implements Checker, Updater {
return update;
}
}

View File

@@ -838,6 +838,8 @@ public class PluginStarter implements Runnable {
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
argVal[i] = argVal[i].replace("$OS", SystemVersion.getOS());
argVal[i] = argVal[i].replace("$ARCH", SystemVersion.getArch());
}
}
ClientApp ca = ctx.routerAppManager().getClientApp(app.className, argVal);
@@ -877,6 +879,8 @@ public class PluginStarter implements Runnable {
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
argVal[i] = argVal[i].replace("$OS", SystemVersion.getOS());
argVal[i] = argVal[i].replace("$ARCH", SystemVersion.getArch());
}
}
@@ -887,6 +891,8 @@ public class PluginStarter implements Runnable {
cp = cp.replace("$I2P", ctx.getBaseDir().getAbsolutePath());
cp = cp.replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
cp = cp.replace("$PLUGIN", pluginDir.getAbsolutePath());
cp = cp.replace("$OS", SystemVersion.getOS());
cp = cp.replace("$ARCH", SystemVersion.getArch());
}
// Old way - add for the whole JVM