Repository: sqoop Updated Branches: refs/heads/sqoop2 b71f55e4e -> 38ae8870a
SQOOP-2814: Sqoop2: Create system wide rc file for the shell (Abraham Fine via Jarek Jarcec Cecho) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/38ae8870 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/38ae8870 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/38ae8870 Branch: refs/heads/sqoop2 Commit: 38ae8870a645abc6050356ea73984353f92e5055 Parents: b71f55e Author: Jarek Jarcec Cecho <[email protected]> Authored: Tue Feb 2 12:07:33 2016 -0800 Committer: Jarek Jarcec Cecho <[email protected]> Committed: Tue Feb 2 12:07:33 2016 -0800 ---------------------------------------------------------------------- .../java/org/apache/sqoop/shell/SqoopShell.java | 16 +++++++++++++--- .../java/org/apache/sqoop/shell/core/Constants.java | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/38ae8870/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java ---------------------------------------------------------------------- diff --git a/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java b/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java index 4aabfcc..c5182c0 100644 --- a/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java +++ b/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java @@ -46,6 +46,7 @@ public final class SqoopShell { * Location of resource file that can contain few initial commands that will * be loaded during each client execution. */ + private static final String SYSTEM_RC_FILE = "sqoop2rc"; private static final String RC_FILE = ".sqoop2rc"; /** @@ -124,14 +125,23 @@ public final class SqoopShell { // We're running in batch mode by default setInteractive(false); + // Let's see if there is a system level RC file with some initial commands + File systemRcFile = new File(Constants.SYSTEM_RC_DIR, SYSTEM_RC_FILE); + + if(systemRcFile.exists()) { + printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADRC, SYSTEM_RC_FILE); + interpretFileContent(systemRcFile, shell); + printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADEDRC); + } + // Let's see if user do have resource file with initial commands that he // would like to apply. String homeDir = System.getProperty(Constants.PROP_HOMEDIR); - File rcFile = new File(homeDir, RC_FILE); + File userRcFile = new File(homeDir, RC_FILE); - if(rcFile.exists()) { + if(userRcFile.exists()) { printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADRC, RC_FILE); - interpretFileContent(rcFile, shell); + interpretFileContent(userRcFile, shell); printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADEDRC); } http://git-wip-us.apache.org/repos/asf/sqoop/blob/38ae8870/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java ---------------------------------------------------------------------- diff --git a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java index 9c57a2e..8af53f2 100644 --- a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java +++ b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java @@ -141,6 +141,8 @@ public class Constants { public static final String PROP_CURDIR = "user.dir"; public static final String SQOOP_PROMPT = "sqoop"; + public static final String SYSTEM_RC_DIR = "/etc/sqoop2/conf"; + // Shared resources public static final String RES_SHARED_USAGE = "shared.usage"; public static final String RES_SHARED_UNKNOWN_FUNCTION = "shared.unknown.function";
