change message

This commit is contained in:
idk
2022-09-19 19:31:21 -04:00
parent b485d0630f
commit a54feb9550
3 changed files with 31 additions and 21 deletions

View File

@ -12,7 +12,7 @@ import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class CopyConfigDir {
public class CopyConfigDir extends WindowsServiceUtil {
static final Logger logger = Logger.getLogger("configlog");
public static void initLogger() {
@ -152,20 +152,6 @@ public class CopyConfigDir {
return i2p;
}
/**
* get the OS name(windows, mac, linux only)
*
* @return os name in lower-case, "windows" "mac" or "linux"
*/
protected static String osName() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows"))
return "windows";
if (osName.contains("mac"))
return "mac";
return "linux";
}
/**
* get the path to the java home, for jpackage this is related to the
* executable itself, which is handy to know. It's a directory called runtime,

View File

@ -33,7 +33,7 @@ public class WinLauncher extends CopyConfigDir {
static WindowsUpdatePostProcessor wupp = null;
private static Router i2pRouter;
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
setupLauncher();
initLogger();
boolean privateBrowsing = false;
@ -88,6 +88,12 @@ public class WinLauncher extends CopyConfigDir {
File programs = programFile();
File home = homeDir();
boolean continuerunning = promptServiceStartIfAvailable("i2p");
if (!continuerunning){
logger.severe("Service startup failure, please start I2P service with services.msc");
System.exit(2);
}
// This actually does most of what we use NSIS for if NSIS hasn't
// already done it, which essentially makes this whole thing portable.
if (!copyConfigDir()) {

View File

@ -105,19 +105,23 @@ public class WindowsServiceUtil {
return false;
}
public static void promptServiceStartIfAvailable(String serviceName) {
public static boolean promptServiceStartIfAvailable(String serviceName) {
if (osName() != "windows"){
return true;
}
if (isInstalled(serviceName)) {
if (!isStart(serviceName)) {
int a;
String message =
"It appears you have an existing I2P service installed.\n";
message +=
"However, it is not running yet. Would you like to start it?\n";
"However, it is not running yet. Please start it through `services.msc`.\n";
a = JOptionPane.showConfirmDialog(null, message,
"I2P Service detected not running",
JOptionPane.YES_NO_OPTION);
if (a == JOptionPane.NO_OPTION) {
// Do nothing here, this will continue on to launch a jpackaged router
return true;
} else {
// We can't just call `net start` or `sc start` directly, that throws
// a permission error. We can start services.msc though, where the
@ -125,11 +129,11 @@ public class WindowsServiceUtil {
// elevation here? May need to refactor Elevator and Shell32X to
// achieve it though
}
} else {
// Here, the service is already started, so I2P should appear to be
// running to the other checks.
return isStart("i2p");
}
return true;
}
return true;
}
public static String getServiceState(String serviceName) {
@ -160,6 +164,20 @@ public class WindowsServiceUtil {
}
return stateString;
}
/**
* get the OS name(windows, mac, linux only)
*
* @return os name in lower-case, "windows" "mac" or "linux"
*/
protected static String osName() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows"))
return "windows";
if (osName.contains("mac"))
return "mac";
return "linux";
}
public static void main(String args[]) {
// when querying the I2P router service installed by the IzPack installer
// this is the correct call.