mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Support -Dlaunchserver.dir.modules and -Dlaunchserver.dir.launcher-modules
This commit is contained in:
parent
03d53d4a09
commit
df9d05a49c
3 changed files with 15 additions and 6 deletions
|
@ -82,6 +82,8 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
||||||
*/
|
*/
|
||||||
public final Path profilesDir;
|
public final Path profilesDir;
|
||||||
public final Path tmpDir;
|
public final Path tmpDir;
|
||||||
|
public final Path modulesDir;
|
||||||
|
public final Path launcherModulesDir;
|
||||||
/**
|
/**
|
||||||
* This object contains runtime configuration
|
* This object contains runtime configuration
|
||||||
*/
|
*/
|
||||||
|
@ -136,6 +138,8 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
launcherLibraries = directories.launcherLibrariesDir;
|
launcherLibraries = directories.launcherLibrariesDir;
|
||||||
launcherLibrariesCompile = directories.launcherLibrariesCompileDir;
|
launcherLibrariesCompile = directories.launcherLibrariesCompileDir;
|
||||||
launcherPack = directories.launcherPackDir;
|
launcherPack = directories.launcherPackDir;
|
||||||
|
modulesDir = directories.modules;
|
||||||
|
launcherModulesDir = directories.launcherModules;
|
||||||
this.shardId = shardId;
|
this.shardId = shardId;
|
||||||
if(!Files.isDirectory(launcherPack)) {
|
if(!Files.isDirectory(launcherPack)) {
|
||||||
Files.createDirectories(launcherPack);
|
Files.createDirectories(launcherPack);
|
||||||
|
@ -488,7 +492,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
||||||
public static class LaunchServerDirectories {
|
public static class LaunchServerDirectories {
|
||||||
public static final String UPDATES_NAME = "updates", PROFILES_NAME = "profiles",
|
public static final String UPDATES_NAME = "updates", PROFILES_NAME = "profiles",
|
||||||
TRUSTSTORE_NAME = "truststore", LAUNCHERLIBRARIES_NAME = "launcher-libraries",
|
TRUSTSTORE_NAME = "truststore", LAUNCHERLIBRARIES_NAME = "launcher-libraries",
|
||||||
LAUNCHERLIBRARIESCOMPILE_NAME = "launcher-libraries-compile", LAUNCHERPACK_NAME = "launcher-pack", KEY_NAME = ".keys";
|
LAUNCHERLIBRARIESCOMPILE_NAME = "launcher-libraries-compile", LAUNCHERPACK_NAME = "launcher-pack", KEY_NAME = ".keys", MODULES = "modules", LAUNCHER_MODULES = "launcher-modules";
|
||||||
public Path updatesDir;
|
public Path updatesDir;
|
||||||
public Path profilesDir;
|
public Path profilesDir;
|
||||||
public Path launcherLibrariesDir;
|
public Path launcherLibrariesDir;
|
||||||
|
@ -498,6 +502,8 @@ public static class LaunchServerDirectories {
|
||||||
public Path dir;
|
public Path dir;
|
||||||
public Path trustStore;
|
public Path trustStore;
|
||||||
public Path tmpDir;
|
public Path tmpDir;
|
||||||
|
public Path modules;
|
||||||
|
public Path launcherModules;
|
||||||
|
|
||||||
public void collect() {
|
public void collect() {
|
||||||
if (updatesDir == null) updatesDir = getPath(UPDATES_NAME);
|
if (updatesDir == null) updatesDir = getPath(UPDATES_NAME);
|
||||||
|
@ -509,6 +515,8 @@ public void collect() {
|
||||||
if(launcherPackDir == null)
|
if(launcherPackDir == null)
|
||||||
launcherPackDir = getPath(LAUNCHERPACK_NAME);
|
launcherPackDir = getPath(LAUNCHERPACK_NAME);
|
||||||
if (keyDirectory == null) keyDirectory = getPath(KEY_NAME);
|
if (keyDirectory == null) keyDirectory = getPath(KEY_NAME);
|
||||||
|
if (modules == null) modules = getPath(MODULES);
|
||||||
|
if (launcherModules == null) launcherModules = getPath(LAUNCHER_MODULES);
|
||||||
if (tmpDir == null)
|
if (tmpDir == null)
|
||||||
tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("launchserver-%s".formatted(SecurityHelper.randomStringToken()));
|
tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("launchserver-%s".formatted(SecurityHelper.randomStringToken()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,13 @@ public static void main(String[] args) throws Exception {
|
||||||
try {
|
try {
|
||||||
Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
|
Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
||||||
LogHelper.error("Library BouncyCastle not found! Is directory 'libraries' empty?");
|
LogHelper.error("Library BouncyCastle not found! Is directory 'libraries' empty?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LaunchServer.LaunchServerDirectories directories = new LaunchServer.LaunchServerDirectories();
|
||||||
|
directories.dir = dir;
|
||||||
|
directories.collect();
|
||||||
CertificateManager certificateManager = new CertificateManager();
|
CertificateManager certificateManager = new CertificateManager();
|
||||||
try {
|
try {
|
||||||
certificateManager.readTrustStore(dir.resolve("truststore"));
|
certificateManager.readTrustStore(dir.resolve("truststore"));
|
||||||
|
@ -79,7 +82,7 @@ public static void main(String[] args) throws Exception {
|
||||||
LaunchServerRuntimeConfig runtimeConfig;
|
LaunchServerRuntimeConfig runtimeConfig;
|
||||||
LaunchServerConfig config;
|
LaunchServerConfig config;
|
||||||
LaunchServer.LaunchServerEnv env = LaunchServer.LaunchServerEnv.PRODUCTION;
|
LaunchServer.LaunchServerEnv env = LaunchServer.LaunchServerEnv.PRODUCTION;
|
||||||
LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(dir.resolve("modules"), dir.resolve("config"), certificateManager.trustManager);
|
LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(directories.modules, dir.resolve("config"), certificateManager.trustManager);
|
||||||
modulesManager.autoload();
|
modulesManager.autoload();
|
||||||
modulesManager.initModules(null);
|
modulesManager.initModules(null);
|
||||||
registerAll();
|
registerAll();
|
||||||
|
@ -124,8 +127,6 @@ public static void main(String[] args) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchServer.LaunchServerConfigManager launchServerConfigManager = new BasicLaunchServerConfigManager(configFile, runtimeConfigFile);
|
LaunchServer.LaunchServerConfigManager launchServerConfigManager = new BasicLaunchServerConfigManager(configFile, runtimeConfigFile);
|
||||||
LaunchServer.LaunchServerDirectories directories = new LaunchServer.LaunchServerDirectories();
|
|
||||||
directories.dir = dir;
|
|
||||||
LaunchServer server = new LaunchServerBuilder()
|
LaunchServer server = new LaunchServerBuilder()
|
||||||
.setDirectories(directories)
|
.setDirectories(directories)
|
||||||
.setEnv(env)
|
.setEnv(env)
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class LauncherModuleLoader {
|
||||||
|
|
||||||
public LauncherModuleLoader(LaunchServer server) {
|
public LauncherModuleLoader(LaunchServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
modulesDir = server.dir.resolve("launcher-modules");
|
modulesDir = server.launcherModulesDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
Loading…
Reference in a new issue