mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Адекватная поддержка Docker.
This commit is contained in:
parent
aa4d4881c8
commit
37e3991a9a
3 changed files with 23 additions and 8 deletions
|
@ -247,15 +247,22 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
|||
public static final Class<? extends LauncherBinary> defaultLauncherEXEBinaryClass = null;
|
||||
|
||||
public static class LaunchServerDirectories {
|
||||
public static final String UPDATES_NAME = "updates", PROFILES_NAME = "profiles",
|
||||
TRUSTSTORE_NAME = "truststore", LAUNCHERLIBRARIES_NAME = "launcher-libraries",
|
||||
LAUNCHERLIBRARIESCOMPILE_NAME = "launcher-libraries-compile";
|
||||
public Path updatesDir;
|
||||
public Path profilesDir;
|
||||
public Path launcherLibrariesDir;
|
||||
public Path launcherLibrariesCompileDir;
|
||||
public Path dir;
|
||||
public Path trustStore;
|
||||
|
||||
public void collect() {
|
||||
if (updatesDir == null) updatesDir = dir.resolve("updates");
|
||||
if (profilesDir == null) profilesDir = dir.resolve("profiles");
|
||||
if (trustStore == null) trustStore = dir.resolve("truststore");
|
||||
if (updatesDir == null) updatesDir = dir.resolve(UPDATES_NAME);
|
||||
if (profilesDir == null) profilesDir = dir.resolve(PROFILES_NAME);
|
||||
if (trustStore == null) trustStore = dir.resolve(TRUSTSTORE_NAME);
|
||||
if (launcherLibrariesDir == null) launcherLibrariesDir = dir.resolve(LAUNCHERLIBRARIES_NAME);
|
||||
if (launcherLibrariesCompileDir == null) launcherLibrariesCompileDir = dir.resolve(LAUNCHERLIBRARIESCOMPILE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,8 +280,8 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
|||
this.runtime = runtimeConfig;
|
||||
this.certificateManager = certificateManager;
|
||||
taskPool = new Timer("Timered task worker thread", true);
|
||||
launcherLibraries = dir.resolve("launcher-libraries");
|
||||
launcherLibrariesCompile = dir.resolve("launcher-libraries-compile");
|
||||
launcherLibraries = directories.launcherLibrariesDir;
|
||||
launcherLibrariesCompile = directories.launcherLibrariesCompileDir;
|
||||
|
||||
config.setLaunchServer(this);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
public class LaunchServerStarter {
|
||||
public static final boolean allowUnsigned = Boolean.getBoolean("launchserver.allowUnsigned");
|
||||
public static final boolean inDocker = Boolean.getBoolean("launchserver.dockered");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
JVMHelper.checkStackTrace(LaunchServerStarter.class);
|
||||
|
@ -177,9 +178,15 @@ public void writeRuntimeConfig(LaunchServerRuntimeConfig config) throws IOExcept
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
LaunchServer.LaunchServerDirectories directories = new LaunchServer.LaunchServerDirectories();
|
||||
directories.dir = dir;
|
||||
if (inDocker) {
|
||||
Path parentLibraries = StarterAgent.libraries.toAbsolutePath().normalize().getParent();
|
||||
directories.launcherLibrariesCompileDir = parentLibraries.resolve(LaunchServer.LaunchServerDirectories.LAUNCHERLIBRARIESCOMPILE_NAME);
|
||||
directories.launcherLibrariesDir = parentLibraries.resolve(LaunchServer.LaunchServerDirectories.LAUNCHERLIBRARIES_NAME);
|
||||
}
|
||||
LaunchServer server = new LaunchServerBuilder()
|
||||
.setDir(dir)
|
||||
.setDirectories(directories)
|
||||
.setEnv(env)
|
||||
.setCommandHandler(localCommandHandler)
|
||||
.setPrivateKey(privateKey)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
|
@ -59,7 +60,7 @@ public static boolean isAgentStarted() {
|
|||
|
||||
public static void premain(String agentArgument, Instrumentation inst) {
|
||||
StarterAgent.inst = inst;
|
||||
libraries = Paths.get("libraries");
|
||||
libraries = Paths.get(Optional.ofNullable(agentArgument).map(e -> e.trim()).filter(e -> !e.isEmpty()).orElse("libraries"));
|
||||
isStarted = true;
|
||||
try {
|
||||
Files.walkFileTree(libraries, Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new StarterVisitor());
|
||||
|
|
Loading…
Reference in a new issue