Fixes #957 Fluo scripts copy jars into fluo software dir. (#964)
diff --git a/modules/distribution/src/main/config/fluo-env.sh b/modules/distribution/src/main/config/fluo-env.sh
index e027f14..0b29665 100755
--- a/modules/distribution/src/main/config/fluo-env.sh
+++ b/modules/distribution/src/main/config/fluo-env.sh
@@ -14,7 +14,7 @@
## Before fluo-env.sh is loaded, these environment variables are set and can be used in this file:
# cmd - Command that is being called such as oracle, worker, etc.
-# app - Fluo application name
+# app - Fluo application name
# basedir - Root of Fluo installation
# conf - Directory containing Fluo configuration
# lib - Directory containing Fluo libraries
@@ -27,6 +27,8 @@
export HADOOP_PREFIX="${HADOOP_PREFIX:-/path/to/hadoop}"
## Fluo connection properties
export FLUO_CONN_PROPS="${FLUO_CONN_PROPS:-${conf}/fluo-conn.properties}"
+## Fluo temp directory where the fluo script will copy jars from HDFS to the local machine
+export FLUO_TMP="${FLUO_TMP:-/tmp}"
####################################################
# Build JAVA_OPTS variable used by all Fluo commands
diff --git a/modules/distribution/src/main/scripts/fluo b/modules/distribution/src/main/scripts/fluo
index abf5576..4116669 100755
--- a/modules/distribution/src/main/scripts/fluo
+++ b/modules/distribution/src/main/scripts/fluo
@@ -143,8 +143,10 @@
app=${BASH_REMATCH[1]}
verify_app "$app"
check_conn_props
- app_lib=$lib/apps/$1
- mkdir -p "$app_lib"
+ # create a temp dir to fetch application jars to
+ app_lib=$(mktemp -d "$FLUO_TMP"/fluo-"$app"-XXXXXXXXX) || die "fatal: unable to allocate a temporary directory"
+ # schedule removal of app_lib tmp dir when this script exits
+ trap "rm -rf '""$app_lib""'" EXIT HUP INT QUIT TERM
$JAVA org.apache.fluo.command.FluoGetJars -d "$app_lib" "$@"
export CLASSPATH="$conf:$app_lib/*:$CLASSPATH"
else
@@ -225,8 +227,10 @@
app=$2
verify_app "$app"
check_conn_props
- app_lib=$lib/apps/$app
- mkdir -p "$app_lib"
+ # create a temp dir to fetch application jars to
+ app_lib=$(mktemp -d "$FLUO_TMP"/fluo-"$app"-XXXXXXXXX) || die "fatal: unable to allocate a temporary directory"
+ # schedule removal of app_lib tmp dir when this script exits
+ trap "rm -rf '""$app_lib""'" EXIT HUP INT QUIT TERM
$JAVA org.apache.fluo.command.FluoGetJars -d "$app_lib" -a "$app"
export CLASSPATH="$conf:$app_lib/*:$CLASSPATH"
$JAVA org.apache.fluo.command.FluoExec "${@:2}"