diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 67fae76b..d3967ea3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -247,15 +247,22 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO public static final Class 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); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index a91a7a64..ff31bb65 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -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) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java index c6baacd0..ba309020 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java @@ -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());