From 37e3991a9a3a3376dab795698755ce0cbf5e6c23 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Thu, 28 Nov 2019 17:14:06 +0100 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=90=D0=B4=D0=B5=D0=BA=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=BA=D0=B0=20Docker.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 17 ++++++++++++----- .../launchserver/LaunchServerStarter.java | 11 +++++++++-- .../pro/gravit/launchserver/StarterAgent.java | 3 ++- 3 files changed, 23 insertions(+), 8 deletions(-) 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());