From 3950def62b4225e40d5a3c9df7a8c44171a9325f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Mar 2018 12:40:24 +0100 Subject: [SystemCommandTask] Support changing environment --- .../java/org/openslx/taskmanager/api/SystemCommandTask.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'api') diff --git a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java index 3e480de..18c8ecc 100644 --- a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java +++ b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.Map; import org.apache.log4j.Logger; @@ -47,6 +48,7 @@ public abstract class SystemCommandTask extends AbstractTask ProcessBuilder pb = new ProcessBuilder( command ); pb.directory( new File( "/" ) ); + initEnvironment( pb.environment() ); try { @@ -207,6 +209,14 @@ public abstract class SystemCommandTask extends AbstractTask */ protected abstract String[] initCommandLine(); + /** + * Override this to modify the environment of the process to be started. + * @param environment + */ + protected void initEnvironment( Map environment ) + { + } + /** * Called when the process has been successfully started. */ -- cgit v1.2.3-55-g7522