Commits vergleichen
Keine gemeinsamen Commits. "master" und "0.1.1" haben vollständig unterschiedliche Historien.
@ -1,4 +0,0 @@
|
|||||||
# SteamWarLinkManager
|
|
||||||
|
|
||||||
## Installing
|
|
||||||
``java -jar SteamWarLinkManager.java install``
|
|
17
pom.xml
17
pom.xml
@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
<groupId>de.chaos</groupId>
|
<groupId>de.chaos</groupId>
|
||||||
<artifactId>swlnmngr</artifactId>
|
<artifactId>swlnmngr</artifactId>
|
||||||
<version>0.2.0</version>
|
<version>0.1.1</version>
|
||||||
<name>SteamWarLinkManager</name>
|
<name>SteamWarLinkManager</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -67,6 +67,12 @@
|
|||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20211205</version>
|
<version>20211205</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.22</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-cli</groupId>
|
<groupId>commons-cli</groupId>
|
||||||
<artifactId>commons-cli</artifactId>
|
<artifactId>commons-cli</artifactId>
|
||||||
@ -92,10 +98,5 @@
|
|||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>2.11.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -2,6 +2,7 @@ package de.chaos.swlnmngr;
|
|||||||
|
|
||||||
import de.chaos.swlnmngr.config.CLIConfig;
|
import de.chaos.swlnmngr.config.CLIConfig;
|
||||||
import de.chaos.swlnmngr.route.Router;
|
import de.chaos.swlnmngr.route.Router;
|
||||||
|
import lombok.Getter;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@ -11,7 +12,9 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static final Logger logger = LogManager.getLogger(Main.class);
|
private static final Logger logger = LogManager.getLogger(Main.class);
|
||||||
|
@Getter
|
||||||
private static String[] allArgs;
|
private static String[] allArgs;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -20,7 +23,7 @@ public class Main {
|
|||||||
if(CLIConfig.IS_DEBUG) {
|
if(CLIConfig.IS_DEBUG) {
|
||||||
Configurator.setRootLevel(Level.DEBUG);
|
Configurator.setRootLevel(Level.DEBUG);
|
||||||
}
|
}
|
||||||
if(CLIConfig.NO_UPDATE) {
|
if(!CLIConfig.NO_UPDATE) {
|
||||||
UpdateChecker.checkForUpdates();
|
UpdateChecker.checkForUpdates();
|
||||||
}
|
}
|
||||||
logger.debug("Arguments: {}", Arrays.toString(allArgs));
|
logger.debug("Arguments: {}", Arrays.toString(allArgs));
|
||||||
@ -30,12 +33,4 @@ public class Main {
|
|||||||
Router.printRoutes();
|
Router.printRoutes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getAllArgs() {
|
|
||||||
return allArgs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.chaos.swlnmngr;
|
package de.chaos.swlnmngr;
|
||||||
|
|
||||||
import de.chaos.swlnmngr.config.Config;
|
import de.chaos.swlnmngr.config.Config;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
@ -12,10 +13,9 @@ import org.json.JSONTokener;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
|
|
||||||
private UpdateChecker() {}
|
|
||||||
|
|
||||||
private static final URI repoUrl = URI.create("https://steamwar.de/devlabs/api/v1/repos/Chaoscaot/SteamwarLinkManager/releases?draft=false&pre-release=" + Config.PRE_RELEASES + "&page=1&limit=1");
|
private static final URI repoUrl = URI.create("https://steamwar.de/devlabs/api/v1/repos/Chaoscaot/SteamwarLinkManager/releases?draft=false&pre-release=" + Config.PRE_RELEASES + "&page=1&limit=1");
|
||||||
|
|
||||||
public static final String CURRENT_VERSION;
|
public static final String CURRENT_VERSION;
|
||||||
|
@ -4,8 +4,6 @@ import de.chaos.swlnmngr.Main;
|
|||||||
import org.apache.commons.cli.*;
|
import org.apache.commons.cli.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
public class CLIConfig {
|
public class CLIConfig {
|
||||||
|
|
||||||
@ -14,7 +12,6 @@ public class CLIConfig {
|
|||||||
public static final File CONFIG;
|
public static final File CONFIG;
|
||||||
public static final File INSTALL_DIR;
|
public static final File INSTALL_DIR;
|
||||||
public static final String[] ARGS;
|
public static final String[] ARGS;
|
||||||
public static final boolean INSTALL_DIR_IS_SET;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
@ -22,7 +19,7 @@ public class CLIConfig {
|
|||||||
options.addOption(new Option("d", "debug", false, "Set the Log Level to Debug"));
|
options.addOption(new Option("d", "debug", false, "Set the Log Level to Debug"));
|
||||||
options.addOption(new Option("c", "config", true, "Use another Config File"));
|
options.addOption(new Option("c", "config", true, "Use another Config File"));
|
||||||
options.addOption(new Option("i", "installdir", true, "Use other Install Dir"));
|
options.addOption(new Option("i", "installdir", true, "Use other Install Dir"));
|
||||||
options.addOption(new Option("u", "update-checker", false, "Enable the Auto-Update Checker"));
|
options.addOption(new Option("u", "no-update", false, "Disable the Auto-Update Checker"));
|
||||||
|
|
||||||
CommandLine cli = null;
|
CommandLine cli = null;
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
@ -46,21 +43,8 @@ public class CLIConfig {
|
|||||||
NO_UPDATE = cli.hasOption("u");
|
NO_UPDATE = cli.hasOption("u");
|
||||||
if(cli.hasOption("i")) {
|
if(cli.hasOption("i")) {
|
||||||
INSTALL_DIR = new File(cli.getOptionValue("i"));
|
INSTALL_DIR = new File(cli.getOptionValue("i"));
|
||||||
INSTALL_DIR_IS_SET = true;
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
INSTALL_DIR = new File("~/.swlnmngr/");
|
||||||
INSTALL_DIR = new File(CLIConfig.class.getProtectionDomain()
|
|
||||||
.getCodeSource()
|
|
||||||
.getLocation()
|
|
||||||
.toURI()
|
|
||||||
.getPath())
|
|
||||||
.getCanonicalFile()
|
|
||||||
.getParentFile();
|
|
||||||
INSTALL_DIR_IS_SET = false;
|
|
||||||
} catch (IOException | URISyntaxException e) {
|
|
||||||
Main.getLogger().error(e.getMessage(), e);
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(cli.hasOption("c")) {
|
if(cli.hasOption("c")) {
|
||||||
CONFIG = new File(cli.getOptionValue("c"));
|
CONFIG = new File(cli.getOptionValue("c"));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.chaos.swlnmngr.config;
|
package de.chaos.swlnmngr.config;
|
||||||
|
|
||||||
import de.chaos.swlnmngr.Main;
|
import de.chaos.swlnmngr.Main;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
@ -8,11 +9,12 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Objects;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
private static File CONFIG_FILE = new File(CLIConfig.INSTALL_DIR, "config.json");
|
private static final File CONFIG_FILE = new File(CLIConfig.INSTALL_DIR, "config.json");
|
||||||
|
|
||||||
public static final File PROJECT_PATH;
|
public static final File PROJECT_PATH;
|
||||||
public static final File LIB_PATH;
|
public static final File LIB_PATH;
|
||||||
@ -27,10 +29,13 @@ public class Config {
|
|||||||
JSONObject config = null;
|
JSONObject config = null;
|
||||||
try {
|
try {
|
||||||
if(!CONFIG_FILE.exists()) {
|
if(!CONFIG_FILE.exists()) {
|
||||||
config = new JSONObject(new JSONTokener(Objects.requireNonNull(Config.class.getResourceAsStream("/default_config.json"))));
|
if(CONFIG_FILE.getParentFile().mkdir()) {
|
||||||
} else {
|
Main.getLogger().log(Level.DEBUG, "Created Config Folder");
|
||||||
config = new JSONObject(new JSONTokener(new FileInputStream(CONFIG_FILE)));
|
|
||||||
}
|
}
|
||||||
|
Files.write(CONFIG_FILE.toPath(), Config.class.getResourceAsStream("/default_config.json").readAllBytes(), StandardOpenOption.CREATE_NEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
config = new JSONObject(new JSONTokener(new FileInputStream(CONFIG_FILE)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Main.getLogger().fatal("Could not load Config", e);
|
Main.getLogger().fatal("Could not load Config", e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -48,7 +53,8 @@ public class Config {
|
|||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
USERNAME = config.getString("username");
|
JSONObject credentials = config.getJSONObject("credentials");
|
||||||
PASSWORD = config.getString("password");
|
USERNAME = credentials.getString("username");
|
||||||
|
PASSWORD = credentials.getString("password");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.json.JSONTokener;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
@ -17,7 +16,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class InstallRoute implements Route {
|
public class InstallRoute implements Route {
|
||||||
|
|
||||||
private static final String[] defaultFiles = new String[] {"default_swlnmngr.bat", "default_swlnmngr.sh", "default_swlnmngr_admin.bat"};
|
private static final String[] defaultFiles = new String[] {"default_swlnmngr.bat", "default_swlnmngr.sh"};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -27,23 +26,14 @@ public class InstallRoute implements Route {
|
|||||||
@Override
|
@Override
|
||||||
public boolean route(String[] args) {
|
public boolean route(String[] args) {
|
||||||
File installDir = CLIConfig.INSTALL_DIR;
|
File installDir = CLIConfig.INSTALL_DIR;
|
||||||
if (!CLIConfig.INSTALL_DIR_IS_SET) {
|
|
||||||
installDir = new File(System.getProperty("user.home", ".swlnmngr"));
|
|
||||||
}
|
|
||||||
if(!installDir.exists()) {
|
if(!installDir.exists()) {
|
||||||
try {
|
installDir.mkdir();
|
||||||
Files.createDirectories(installDir.toPath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Main.getLogger().error("Could not create Install Directory", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String defaultFile : defaultFiles) {
|
for (String defaultFile : defaultFiles) {
|
||||||
String normalName = defaultFile.replace("default_", "");
|
String normalName = defaultFile.replace("default_", "");
|
||||||
try {
|
try {
|
||||||
Files.copy(Objects.requireNonNull(InstallRoute.class.getResourceAsStream("/" + defaultFile)), new File(installDir, normalName).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(Objects.requireNonNull(InstallRoute.class.getResourceAsStream("/" + defaultFile)), new File(CLIConfig.INSTALL_DIR, normalName).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
new File(installDir, normalName).setExecutable(true, true);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Main.getLogger().error("Could not create File", e);
|
Main.getLogger().error("Could not create File", e);
|
||||||
return false;
|
return false;
|
||||||
@ -52,34 +42,18 @@ public class InstallRoute implements Route {
|
|||||||
|
|
||||||
if(SystemUtils.IS_OS_UNIX) {
|
if(SystemUtils.IS_OS_UNIX) {
|
||||||
try {
|
try {
|
||||||
Files.deleteIfExists(new File(installDir, "swlnmngr").toPath());
|
Files.deleteIfExists(new File(CLIConfig.INSTALL_DIR, "swlnmngr").toPath());
|
||||||
Files.createSymbolicLink(new File(installDir, "swlnmngr").toPath(), new File(installDir, "swlnmngr.sh").toPath());
|
Files.createSymbolicLink(new File(CLIConfig.INSTALL_DIR, "swlnmngr").toPath(), new File(CLIConfig.INSTALL_DIR, "swlnmngr.sh").toPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Main.getLogger().error("Could not create SymLink", e);
|
Main.getLogger().error("Could not create SymLink", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if(SystemUtils.IS_OS_WINDOWS) {
|
|
||||||
try {
|
|
||||||
Files.writeString(new File(installDir, "swlnmngr.bat").toPath(), Files.readString(new File(installDir, "swlnmngr.bat").toPath()).replace("${iDir}", installDir.getAbsolutePath()), StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING);
|
|
||||||
Files.writeString(new File(installDir, "swlnmngr_admin.bat").toPath(), Files.readString(new File(installDir, "swlnmngr_admin.bat").toPath()).replace("${iDir}", installDir.getAbsolutePath()), StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Main.getLogger().error("Could not create Link", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File configFile = new File(installDir, "config.json");
|
File configFile = new File(installDir, "config.json");
|
||||||
if(!configFile.exists()) {
|
if(!configFile.exists()) {
|
||||||
try {
|
try {
|
||||||
String configStr = new String(Objects.requireNonNull(InstallRoute.class.getResourceAsStream("/default_config.json")).readAllBytes());
|
Files.copy(Objects.requireNonNull(InstallRoute.class.getResourceAsStream("/default_config.json")), configFile.toPath());
|
||||||
if(SystemUtils.IS_OS_WINDOWS) {
|
|
||||||
configStr = configStr.replace("~", System.getProperty("user.home"))
|
|
||||||
.replace("\\", "\\\\")
|
|
||||||
.replace("/", "\\\\")
|
|
||||||
.replace("https:\\\\\\\\steamwar.de\\\\lib.php", "https://steamwar.de/lib.php");
|
|
||||||
}
|
|
||||||
Files.writeString(configFile.toPath(), configStr, StandardOpenOption.CREATE_NEW);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Main.getLogger().error("Could not copy Config File", e);
|
Main.getLogger().error("Could not copy Config File", e);
|
||||||
return false;
|
return false;
|
||||||
@ -106,7 +80,7 @@ public class InstallRoute implements Route {
|
|||||||
try {
|
try {
|
||||||
File jar = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
|
File jar = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||||
Main.getLogger().debug(jar);
|
Main.getLogger().debug(jar);
|
||||||
Files.copy(jar.toPath(), new File(installDir, "SteamWarLinkManager.jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(jar.toPath(), new File(CLIConfig.INSTALL_DIR, "SteamWarLinkManager.jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
Main.getLogger().error("Could parse Jar Location", e);
|
Main.getLogger().error("Could parse Jar Location", e);
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,7 +2,6 @@ package de.chaos.swlnmngr.route.routes;
|
|||||||
|
|
||||||
import de.chaos.swlnmngr.Main;
|
import de.chaos.swlnmngr.Main;
|
||||||
import de.chaos.swlnmngr.config.Config;
|
import de.chaos.swlnmngr.config.Config;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -35,15 +34,9 @@ public class LinkRoute implements Route {
|
|||||||
Main.getLogger().error("No Project with name: {}", args[0]);
|
Main.getLogger().error("No Project with name: {}", args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File link = new File(projectDir, "lib");
|
File link = new File(projectDir, "libs");
|
||||||
try {
|
try {
|
||||||
if(link.exists()) {
|
Files.deleteIfExists(link.toPath());
|
||||||
if(link.isDirectory()) {
|
|
||||||
FileUtils.deleteDirectory(link);
|
|
||||||
} else {
|
|
||||||
FileUtils.delete(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Main.getLogger().debug(libsFile);
|
Main.getLogger().debug(libsFile);
|
||||||
Main.getLogger().debug(link);
|
Main.getLogger().debug(link);
|
||||||
Path linkPath = Files.createSymbolicLink(link.toPath(), libsFile.toPath());
|
Path linkPath = Files.createSymbolicLink(link.toPath(), libsFile.toPath());
|
||||||
|
@ -1,17 +1 @@
|
|||||||
@echo off
|
java -jar ./SteamWarLinkManager.jar
|
||||||
:: Variables
|
|
||||||
SET JavaHome=java
|
|
||||||
SET Home=${iDir}
|
|
||||||
|
|
||||||
:: Code
|
|
||||||
title Request Admin
|
|
||||||
|
|
||||||
Net session >nul 2>&1 || (PowerShell start -verb runas '%~0' & exit)
|
|
||||||
|
|
||||||
title SteamWarLinkManager
|
|
||||||
set args=--help
|
|
||||||
set /p args=Arguments:
|
|
||||||
echo %args%
|
|
||||||
%JavaHome% -jar ${iDir}\SteamWarLinkManager.jar %args% %* -i %Home%
|
|
||||||
pause
|
|
||||||
exit
|
|
@ -1,3 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
java -jar ./SteamWarLinkManager.jar
|
||||||
java -jar $parent_path/SteamWarLinkManager.jar $@
|
|
@ -1,5 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
title Admin
|
|
||||||
runas /noprofile /savecred /user:Admin ${iDir}\swlnmngr.bat
|
|
||||||
exit
|
|
In neuem Issue referenzieren
Einen Benutzer sperren