From 31dcd1ebe807c5ab70b5f52cfce17f07a3f9193a Mon Sep 17 00:00:00 2001 From: RPJosh Date: Thu, 28 Dec 2023 21:54:00 +0100 Subject: [PATCH] Don't kill systemd services for portable and improve translations --- src/main/java/de/rpjosh/installer/InstallConfig.java | 2 +- src/main/java/de/rpjosh/installer/Installer.java | 10 ++++++---- .../translation/de-rpjosh-installer_en.properties | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/rpjosh/installer/InstallConfig.java b/src/main/java/de/rpjosh/installer/InstallConfig.java index 55b865b..40f1aaf 100644 --- a/src/main/java/de/rpjosh/installer/InstallConfig.java +++ b/src/main/java/de/rpjosh/installer/InstallConfig.java @@ -405,7 +405,7 @@ public class InstallConfig { this.isPortable = true; this.portableMainDir = dir; - this.configDir = dir + "Appdata/"; + this.configDir = dir + "AppData/"; this.applicationDir = dir + "Programm/"; isPortable = true; diff --git a/src/main/java/de/rpjosh/installer/Installer.java b/src/main/java/de/rpjosh/installer/Installer.java index 17df9c0..00d8a50 100644 --- a/src/main/java/de/rpjosh/installer/Installer.java +++ b/src/main/java/de/rpjosh/installer/Installer.java @@ -243,10 +243,12 @@ public class Installer { } else if (InstallConfig.getOsType() == OSType.LINUX) { // If a service was installed previously try to stop it first. This will fail internal when no service was created - Process p = new ProcessBuilder("bash", "-c", "systemctl stop \"" + conf.getApplicationNameShort() + ".service" + "\"").start(); - p.waitFor(5, TimeUnit.SECONDS); + if (!conf.getIsPortable()) { + Process p = new ProcessBuilder("bash", "-c", "systemctl stop \"" + conf.getApplicationNameShort() + ".service" + "\"").start(); + p.waitFor(5, TimeUnit.SECONDS); + } - p = new ProcessBuilder("bash", "-c", "pkill -9 -f '" + conf.getApplicationNameShort() + ".jar'").start(); + Process p = new ProcessBuilder("bash", "-c", "pkill -9 -f '" + conf.getApplicationNameShort() + ".jar'").start(); p.waitFor(5, TimeUnit.SECONDS); } } catch (Exception ex) { /* not required */ } @@ -1191,7 +1193,7 @@ public class Installer { * that are only needed in edge cases. */ private void finishInstallation() { - if (InstallConfig.getOsType() == OSType.LINUX) { + if (InstallConfig.getOsType() == OSType.LINUX && !conf.getIsPortable()) { try { // Try to start a previously installed service again that was stopped during installation Process p = new ProcessBuilder("bash", "-c", "systemctl start \"" + conf.getApplicationNameShort() + ".service" + "\"").start(); diff --git a/src/main/resources/translation/de-rpjosh-installer_en.properties b/src/main/resources/translation/de-rpjosh-installer_en.properties index 0e93464..728f9f7 100644 --- a/src/main/resources/translation/de-rpjosh-installer_en.properties +++ b/src/main/resources/translation/de-rpjosh-installer_en.properties @@ -1,9 +1,9 @@ root_rights_required=\ -For the installation of the program administrator / root privileges are required.\n\n\ +Administrator / root rights are required to install this program..\n\n\ If you don't have these you can try to install the program portable or only for the currently logged-in user [Windows].\n\ -For further help execute the program via the command line with the parameter "--help". +For further help, run the Installer via the command line with the parameter "--help". root_askForRestart=\ -If you do have such rights the installation can be restarted automatically with root privileges.\n\ +If you have these rights, the installation can be restarted automatically with root privileges.\n\ Would you like to try a restart of the program with root privileges (Y/N)? userInstallation_notAvailable=A user installation is only available for windows @@ -12,8 +12,8 @@ installation_start=Starting the installation of {0} (version {1}) installation_architekture=Determine architecture and operating system installation_download=Downloading file -installation_download_success=Downloading file: successful downloaded -installation_download_invalid=The given file is invalid! +installation_download_success=Downloading file: successfully downloaded +installation_download_invalid=The provided file is invalid! installation_download_failed=An error occurred while downloading the file.\nPlease check your Internet connection and try again later (URL: {0}) installation_download_urlNotFound=The determined URL was not found (URL: {0}); @@ -35,6 +35,6 @@ failed=failed errorMessage=Error Message successful=successful -basicAuthRequired=For downloading the program a authentication is required (HTTP-Code 401) +basicAuthRequired=Authentication is required to download the program (HTTP code 401) username=Username password=Password \ No newline at end of file