You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2017/09/06 11:04:57 UTC

zeppelin git commit: [ZEPPELIN-2903] Make setting of working directory to user-home optional for shell interpreter

Repository: zeppelin
Updated Branches:
  refs/heads/master faa9d8615 -> 629e21769


[ZEPPELIN-2903] Make setting of working directory to user-home optional for shell interpreter

### What is this PR for?
With ZEPPELIN-2841, it had changed the default working directory of Shell Interpreter from the relative path where Zeppelin is running to user-home. This is to make the configuration optional.

### What type of PR is it?
[Improvement]

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-2903

### How should this be tested?
by default when the user runs shell interpreter and executes `pwd` will the path where Zeppelin server is running, but when `shell.working.directory.user.home` is set to true in Zeppelin's interpreter setting, it will point to the user's home directory by which the interpreter is running.

Author: Prabhjyot Singh <pr...@gmail.com>

Closes #2566 from prabhjyotsingh/ZEPPELIN-2903 and squashes the following commits:

9934df52a [Prabhjyot Singh] add doc for shell.working.directory.user.home
9164ed2c0 [Prabhjyot Singh] Make setting of working directory to user-home optional for shell interpreter


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/629e2176
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/629e2176
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/629e2176

Branch: refs/heads/master
Commit: 629e21769e2bda6c3e8d86f650f1ee99e68d917b
Parents: faa9d86
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Tue Sep 5 23:20:15 2017 +0530
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Wed Sep 6 16:34:51 2017 +0530

----------------------------------------------------------------------
 docs/interpreter/shell.md                                     | 5 +++++
 .../main/java/org/apache/zeppelin/shell/ShellInterpreter.java | 6 +++++-
 shell/src/main/resources/interpreter-setting.json             | 7 +++++++
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/629e2176/docs/interpreter/shell.md
----------------------------------------------------------------------
diff --git a/docs/interpreter/shell.md b/docs/interpreter/shell.md
index 9d4bfe7..d285cf4 100644
--- a/docs/interpreter/shell.md
+++ b/docs/interpreter/shell.md
@@ -44,6 +44,11 @@ At the "Interpreters" menu in Zeppelin dropdown menu, you can set the property v
     <td>Shell command time out in millisecs</td>
   </tr>
   <tr>
+    <td>shell.working.directory.user.home</td>
+    <td>false</td>
+    <td>If this set to true, the shell's working directory will be set to user home</td>
+  </tr>
+  <tr>
     <td>zeppelin.shell.auth.type</td>
     <td></td>
     <td>Types of authentications' methods supported are SIMPLE, and KERBEROS</td>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/629e2176/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
index daad0b3..dbae6c9 100644
--- a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
+++ b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
@@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory;
 public class ShellInterpreter extends KerberosInterpreter {
   private static final Logger LOGGER = LoggerFactory.getLogger(ShellInterpreter.class);
   private static final String TIMEOUT_PROPERTY = "shell.command.timeout.millisecs";
+  private static final String DIRECTORY_USER_HOME = "shell.working.directory.user.home";
   private final boolean isWindows = System.getProperty("os.name").startsWith("Windows");
   private final String shell = isWindows ? "cmd /c" : "bash -c";
   ConcurrentHashMap<String, DefaultExecutor> executors;
@@ -99,7 +100,10 @@ public class ShellInterpreter extends KerberosInterpreter {
         contextInterpreter.out, contextInterpreter.out));
       executor.setWatchdog(new ExecuteWatchdog(Long.valueOf(getProperty(TIMEOUT_PROPERTY))));
       executors.put(contextInterpreter.getParagraphId(), executor);
-      executor.setWorkingDirectory(new File(System.getProperty("user.home")));
+      if (Boolean.valueOf(getProperty(DIRECTORY_USER_HOME))) {
+        executor.setWorkingDirectory(new File(System.getProperty("user.home")));
+      }
+
       int exitVal = executor.execute(cmdLine);
       LOGGER.info("Paragraph " + contextInterpreter.getParagraphId() 
         + " return with exit value: " + exitVal);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/629e2176/shell/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/interpreter-setting.json b/shell/src/main/resources/interpreter-setting.json
index 7728d5f..45a9719 100644
--- a/shell/src/main/resources/interpreter-setting.json
+++ b/shell/src/main/resources/interpreter-setting.json
@@ -11,6 +11,13 @@
         "description": "Shell command time out in millisecs. Default = 60000",
         "type": "number"
       },
+      "shell.working.directory.user.home": {
+        "envName": "SHELL_WORKING_DIRECTORY_USER_HOME",
+        "propertyName": "shell.working.directory.user.home",
+        "defaultValue": false,
+        "description": "If this set to true, the shell's working directory will be set to user home",
+        "type": "checkbox"
+      },
       "zeppelin.shell.auth.type": {
         "envName": null,
         "propertyName": "zeppelin.shell.auth.type",