From e0a9b78afc2e1e65b7ff9685f331eb5bbb928c71 Mon Sep 17 00:00:00 2001 From: Jonathan Mercier Date: Fri, 30 Aug 2019 09:52:42 +0200 Subject: [PATCH 1/2] Use gradle installDist to generate starter script --- build.gradle | 6 ++++++ deploy/bin/hdfs_shell.unix.template.sh | 17 +++++++++++++++++ deploy/bin/hdfs_shell.win.template.bat | 12 ++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 deploy/bin/hdfs_shell.unix.template.sh create mode 100644 deploy/bin/hdfs_shell.win.template.bat diff --git a/build.gradle b/build.gradle index c451291..939b5eb 100644 --- a/build.gradle +++ b/build.gradle @@ -84,3 +84,9 @@ dependencies { testCompile("org.springframework.boot:spring-boot-starter-test:1.4.2.RELEASE") } +startScripts{ + applicationName = 'hdfs-shell' + unixStartScriptGenerator.template = resources.text.fromFile('deploy/bin/hdfs_shell.unix.template.sh') + windowsStartScriptGenerator.template = resources.text.fromFile('deploy/bin/hdfs_shell.win.template.bat') +} + diff --git a/deploy/bin/hdfs_shell.unix.template.sh b/deploy/bin/hdfs_shell.unix.template.sh new file mode 100644 index 0000000..cea7927 --- /dev/null +++ b/deploy/bin/hdfs_shell.unix.template.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +SCRIPT_FULL_PATH="\$(readlink -f "\${BASH_SOURCE[0]}")" +BIN_DIR="\$(dirname "\${SCRIPT_FULL_PATH}")" +LIB_DIR="\$(readlink -f "\${BIN_DIR}/../lib")" +HADOOP_DIR="\${HADOOP_CONF_DIR:-/etc/hadoop/conf}" +HADOOP_CLASSPATH="\${HADOOP_CLASSPATH:-\$(hadoop classpath)}" +command_args=(java -Xms200m -Xmx400m -cp "\${LIB_DIR}/*:\${HADOOP_DIR}:\${HADOOP_CLASSPATH}") +echo "Launching HDFS Shell with HADOOP_CONF_DIR: \${HADOOP_DIR}" + +while (( \$# > 0 )); do + case "\$1" in + -d|--daemon) command_args+=('-Ddaemon=true'); shift;; + esac + shift +done +command_args+=( ${mainClassName} "\$@") +command "\${command_args[@]}" \ No newline at end of file diff --git a/deploy/bin/hdfs_shell.win.template.bat b/deploy/bin/hdfs_shell.win.template.bat new file mode 100644 index 0000000..9e6a455 --- /dev/null +++ b/deploy/bin/hdfs_shell.win.template.bat @@ -0,0 +1,12 @@ +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%.. +set LIB_DIR=%APP_HOME%/lib + +echo Launching HDFS Shell with HADOOP_CONF_DIR: %HADOOP_DIR% +java.exe -Xms200m -Xmx400m -cp "%LIB_DIR%/*:%HADOOP_DIR%:%HADOOP_CLASSPATH%" ${mainClassName} %CMD_LINE_ARGS% +if "%OS%"=="Windows_NT" endlocal \ No newline at end of file From 2c61a509982d81f4dd518664c604d39326431cb0 Mon Sep 17 00:00:00 2001 From: Jonathan Mercier Date: Fri, 30 Aug 2019 10:10:41 +0200 Subject: [PATCH 2/2] use windows separator --- deploy/bin/hdfs_shell.win.template.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/bin/hdfs_shell.win.template.bat b/deploy/bin/hdfs_shell.win.template.bat index 9e6a455..b48afc1 100644 --- a/deploy/bin/hdfs_shell.win.template.bat +++ b/deploy/bin/hdfs_shell.win.template.bat @@ -8,5 +8,5 @@ set APP_HOME=%DIRNAME%.. set LIB_DIR=%APP_HOME%/lib echo Launching HDFS Shell with HADOOP_CONF_DIR: %HADOOP_DIR% -java.exe -Xms200m -Xmx400m -cp "%LIB_DIR%/*:%HADOOP_DIR%:%HADOOP_CLASSPATH%" ${mainClassName} %CMD_LINE_ARGS% +java.exe -Xms200m -Xmx400m -cp "%LIB_DIR%/*;%HADOOP_DIR%:%HADOOP_CLASSPATH%" ${mainClassName} %CMD_LINE_ARGS% if "%OS%"=="Windows_NT" endlocal \ No newline at end of file