monitor execution of update installer for errors
This commit is contained in:
3
Makefile
3
Makefile
@ -11,6 +11,9 @@ PROFILE_VERSION=$(MAJOR).$(MINOR).$(BUILD)
|
|||||||
|
|
||||||
all: version prep install.exe
|
all: version prep install.exe
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
find . -name '*.java' -exec clang-format -i {} \;
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
git tag $(PROFILE_VERSION)
|
git tag $(PROFILE_VERSION)
|
||||||
|
|
||||||
|
@ -66,18 +66,21 @@ public class CopyConfigDir extends WindowsServiceUtil {
|
|||||||
if (0 == cnr)
|
if (0 == cnr)
|
||||||
return false;
|
return false;
|
||||||
if (1 == cnr) {
|
if (1 == cnr) {
|
||||||
logger.info("using jpackaged configs in a jpackaged install, creating jpackaged file");
|
logger.info(
|
||||||
|
"using jpackaged configs in a jpackaged install, creating jpackaged file");
|
||||||
File jpackagedConfigsInUse = new File(appImageHome(), "jpackaged");
|
File jpackagedConfigsInUse = new File(appImageHome(), "jpackaged");
|
||||||
if (!jpackagedConfigsInUse.exists()) {
|
if (!jpackagedConfigsInUse.exists()) {
|
||||||
try {
|
try {
|
||||||
jpackagedConfigsInUse.createNewFile();
|
jpackagedConfigsInUse.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warning("Error creating jpackaged file, delete config files manually when uninstalling");
|
logger.warning(
|
||||||
|
"Error creating jpackaged file, delete config files manually when uninstalling");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (-1 == cnr) {
|
if (-1 == cnr) {
|
||||||
logger.info("not overwriting existing config file, not creating jpackaged file");
|
logger.info(
|
||||||
|
"not overwriting existing config file, not creating jpackaged file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,8 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
i2pRouter = new Router(routerconf, System.getProperties());
|
i2pRouter = new Router(routerconf, System.getProperties());
|
||||||
String newsURL = i2pRouter.getConfigSetting("router.newsURL");
|
String newsURL = i2pRouter.getConfigSetting("router.newsURL");
|
||||||
if (newsURL != null) {
|
if (newsURL != null) {
|
||||||
if (newsURL.contains("http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/win/beta/news.su3")) {
|
if (newsURL.contains(
|
||||||
|
"http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/win/beta/news.su3")) {
|
||||||
logger.info(
|
logger.info(
|
||||||
"checked router.newsURL config, containes win/beta in a service install, invalid update type");
|
"checked router.newsURL config, containes win/beta in a service install, invalid update type");
|
||||||
if (i2pRouter.saveConfig("router.newsURL", ServiceUpdaterString())) {
|
if (i2pRouter.saveConfig("router.newsURL", ServiceUpdaterString())) {
|
||||||
@ -183,7 +184,8 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
}
|
}
|
||||||
String backupNewsURL = i2pRouter.getConfigSetting("router.backupNewsURL");
|
String backupNewsURL = i2pRouter.getConfigSetting("router.backupNewsURL");
|
||||||
if (backupNewsURL != null) {
|
if (backupNewsURL != null) {
|
||||||
if (backupNewsURL.contains("http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/win/beta/news.su3")) {
|
if (backupNewsURL.contains(
|
||||||
|
"http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/win/beta/news.su3")) {
|
||||||
logger.info(
|
logger.info(
|
||||||
"checked router.backupNewsURL config, containes win/beta in a service install, invalid update type");
|
"checked router.backupNewsURL config, containes win/beta in a service install, invalid update type");
|
||||||
if (i2pRouter.saveConfig("router.backupNewsURL",
|
if (i2pRouter.saveConfig("router.backupNewsURL",
|
||||||
@ -195,7 +197,8 @@ public class WinLauncher extends CopyConfigDir {
|
|||||||
}
|
}
|
||||||
String updateURL = i2pRouter.getConfigSetting("router.updateURL");
|
String updateURL = i2pRouter.getConfigSetting("router.updateURL");
|
||||||
if (updateURL != null) {
|
if (updateURL != null) {
|
||||||
if (updateURL.contains("http://ekm3fu6fr5pxudhwjmdiea5dovc3jdi66hjgop4c7z7dfaw7spca.b32.i2p/i2pwinupdate.su3")) {
|
if (updateURL.contains(
|
||||||
|
"http://ekm3fu6fr5pxudhwjmdiea5dovc3jdi66hjgop4c7z7dfaw7spca.b32.i2p/i2pwinupdate.su3")) {
|
||||||
logger.info(
|
logger.info(
|
||||||
"checked router.updateURL config, containes easy-intall update in a service install, invalid update type");
|
"checked router.updateURL config, containes easy-intall update in a service install, invalid update type");
|
||||||
if (i2pRouter.saveConfig("router.updateURL",
|
if (i2pRouter.saveConfig("router.updateURL",
|
||||||
|
@ -62,13 +62,22 @@ class WinUpdateProcess implements Runnable {
|
|||||||
env.put("RESTART_I2P", "true");
|
env.put("RESTART_I2P", "true");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pb.directory(workingDir)
|
Process p = pb.directory(workingDir)
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.redirectOutput(logFile)
|
.redirectOutput(logFile)
|
||||||
.start();
|
.start();
|
||||||
|
exitCode = p.waitFor();
|
||||||
|
if (exitCode != 0)
|
||||||
|
_log.error("Update failed with exit code " + exitCode + " see " +
|
||||||
|
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.");
|
"Unable to run update program in background. Update will fail.",
|
||||||
|
ex);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
_log.error(
|
||||||
|
"Unable to run update program in background. Update will fail.",
|
||||||
|
ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we cant write to the log file and we're on Windows, use the elevator
|
// If we cant write to the log file and we're on Windows, use the elevator
|
||||||
|
@ -39,6 +39,20 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor {
|
|||||||
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 (fileType != SU3File.TYPE_ZIP) {
|
||||||
|
this.positionedFile = moveUpdateInstaller(file);
|
||||||
|
this.version = version;
|
||||||
|
|
||||||
|
if (!hook.compareAndSet(false, true)) {
|
||||||
|
_log.info("shutdown hook was already set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_log.info("adding shutdown hook");
|
||||||
|
|
||||||
|
ctx.addFinalShutdownTask(
|
||||||
|
new ZipUpdateProcess(ctx, this::getVersion, this::getFile));
|
||||||
|
}
|
||||||
if (SystemVersion.isWindows()) {
|
if (SystemVersion.isWindows()) {
|
||||||
|
|
||||||
if (type != UpdateType.ROUTER_SIGNED_SU3 &&
|
if (type != UpdateType.ROUTER_SIGNED_SU3 &&
|
||||||
|
82
java/net/i2p/router/ZipUpdateProcess.java
Normal file
82
java/net/i2p/router/ZipUpdateProcess.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package net.i2p.router;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.*;
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.router.*;
|
||||||
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
|
public class ZipUpdateProcess implements Runnable {
|
||||||
|
private final RouterContext ctx;
|
||||||
|
private final Supplier<String> versionSupplier;
|
||||||
|
private final Supplier<File> fileSupplier;
|
||||||
|
private final Log _log;
|
||||||
|
|
||||||
|
ZipUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier,
|
||||||
|
Supplier<File> fileSupplier) {
|
||||||
|
this.ctx = ctx;
|
||||||
|
this.versionSupplier = versionSupplier;
|
||||||
|
this.fileSupplier = fileSupplier;
|
||||||
|
this._log = ctx.logManager().getLog(ZipUpdateProcess.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private File workDir() throws IOException {
|
||||||
|
if (ctx != null) {
|
||||||
|
File workDir =
|
||||||
|
new File(ctx.getConfigDir().getAbsolutePath(), "i2p_update_win");
|
||||||
|
if (workDir.exists()) {
|
||||||
|
if (workDir.isFile())
|
||||||
|
throw new IOException(workDir +
|
||||||
|
" exists but is a file, get it out of the way");
|
||||||
|
return workDir;
|
||||||
|
} else {
|
||||||
|
workDir.mkdirs();
|
||||||
|
}
|
||||||
|
return workDir;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unzipUpdateInstaller() throws IOException {
|
||||||
|
String version = versionSupplier.get();
|
||||||
|
File file = fileSupplier.get();
|
||||||
|
if (file == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
File workingDir = workDir();
|
||||||
|
File logFile = new File(workingDir, "log-" + version + ".txt");
|
||||||
|
|
||||||
|
// check if we can write to the log file. If we can, use the
|
||||||
|
// ProcessBuilder to run the installer.
|
||||||
|
// ProcessBuilder pb = new ProcessBuilder(
|
||||||
|
// file.getAbsolutePath(), "/S", "/D=" + workingDir.getAbsolutePath());
|
||||||
|
// Map<String, String> env = pb.environment();
|
||||||
|
// env.put("OLD_I2P_VERSION", version);
|
||||||
|
// env.remove("RESTART_I2P");
|
||||||
|
|
||||||
|
int exitCode = ctx.router().scheduledGracefulExitCode();
|
||||||
|
// if (exitCode == Router.EXIT_HARD_RESTART ||
|
||||||
|
// exitCode == Router.EXIT_GRACEFUL_RESTART)
|
||||||
|
// env.put("RESTART_I2P", "true");
|
||||||
|
|
||||||
|
/*try {
|
||||||
|
pb.directory(workingDir)
|
||||||
|
.redirectErrorStream(true)
|
||||||
|
.redirectOutput(logFile)
|
||||||
|
.start();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
_log.error(
|
||||||
|
"Unable to run update-program in background. Update will fail.", ex);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
unzipUpdateInstaller();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
_log.error("Error running updater, update may fail." + ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -76,10 +76,12 @@ cd java
|
|||||||
net/i2p/router/CopyConfigDir.java \
|
net/i2p/router/CopyConfigDir.java \
|
||||||
net/i2p/router/Elevator.java \
|
net/i2p/router/Elevator.java \
|
||||||
net/i2p/router/Shell32X.java \
|
net/i2p/router/Shell32X.java \
|
||||||
|
net/i2p/router/WindowsServiceUtil.java \
|
||||||
net/i2p/router/WinLauncher.java \
|
net/i2p/router/WinLauncher.java \
|
||||||
net/i2p/router/WindowsUpdatePostProcessor.java \
|
net/i2p/router/WindowsUpdatePostProcessor.java \
|
||||||
net/i2p/router/WinUpdateProcess.java \
|
net/i2p/router/WinUpdateProcess.java \
|
||||||
net/i2p/router/WindowsServiceUtil.java
|
net/i2p/router/WindowsServiceUtil.java \
|
||||||
|
net/i2p/router/ZipUpdateProcess.java
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user