Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x d7acdb729 -> 27a129ba1


[KARAF-3978]enable specify different shell.init.script env for remote shell in 
exec and shell mode


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/27a129ba
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/27a129ba
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/27a129ba

Branch: refs/heads/karaf-3.0.x
Commit: 27a129ba155c50b6c4b853c16c0a5ef72fad0f0a
Parents: d7acdb7
Author: Freeman Fang <[email protected]>
Authored: Wed Sep 9 13:49:16 2015 +0800
Committer: Freeman Fang <[email protected]>
Committed: Wed Sep 9 13:49:16 2015 +0800

----------------------------------------------------------------------
 .../java/org/apache/karaf/shell/ssh/ShellCommand.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/27a129ba/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
index b68ca53..35a499f 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
 public class ShellCommand implements Command, Runnable, SessionAware {
 
     public static final String SHELL_INIT_SCRIPT = "karaf.shell.init.script";
+    public static final String EXEC_INIT_SCRIPT = "karaf.exec.init.script";
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(ShellCommand.class);
 
@@ -125,7 +126,10 @@ public class ShellCommand implements Command, Runnable, 
SessionAware {
                     try {
                         result = JaasHelper.doAs(subject, new 
PrivilegedExceptionAction<Object>() {
                             public Object run() throws Exception {
-                                String scriptFileName = 
System.getProperty(SHELL_INIT_SCRIPT);
+                                String scriptFileName = 
System.getProperty(EXEC_INIT_SCRIPT);
+                                if (scriptFileName == null) {
+                                    scriptFileName = 
System.getProperty(SHELL_INIT_SCRIPT);
+                                }
                                 executeScript(scriptFileName, commandSession);
                                 return commandSession.execute(command);
                             }
@@ -134,7 +138,10 @@ public class ShellCommand implements Command, Runnable, 
SessionAware {
                         throw e.getException();
                     }
                 } else {
-                    String scriptFileName = 
System.getProperty(SHELL_INIT_SCRIPT);
+                    String scriptFileName = 
System.getProperty(EXEC_INIT_SCRIPT);
+                    if (scriptFileName == null) {
+                        scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
+                    }
                     executeScript(scriptFileName, commandSession);
                     result = commandSession.execute(command);
                 }

Reply via email to