From ff3bab7d545638ffbf47b732e00fb6561d1867e4 Mon Sep 17 00:00:00 2001 From: Patrick Wong Date: Thu, 12 Mar 2015 14:48:05 -0700 Subject: [PATCH] DRILL-2446: Improvement in finding Drill log dir --- distribution/src/resources/drill-config.sh | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/distribution/src/resources/drill-config.sh b/distribution/src/resources/drill-config.sh index 0ee181d27b6..7ddec65cf7e 100644 --- a/distribution/src/resources/drill-config.sh +++ b/distribution/src/resources/drill-config.sh @@ -78,20 +78,21 @@ fi . "${DRILL_CONF_DIR}/drill-env.sh" # get log directory -if [ "$DRILL_LOG_DIR" = "" ]; then - DRILL_LOG_DIR=/var/log/drill - touch $DRILL_LOG_DIR/sqlline.log - TOUCH_EXIT_CODE=$? - if [ $TOUCH_EXIT_CODE = 0 ]; then - echo "Default Drill log directory: $DRILL_LOG_DIR" - DRILL_LOG_DIR_FALLBACK=0 - else - #Force DRILL_LOG_DIR to fall back - DRILL_LOG_DIR_FALLBACK=1 - fi +if [ "x${DRILL_LOG_DIR}" = "x" ]; then + export DRILL_LOG_DIR=/var/log/drill +fi + +touch "$DRILL_LOG_DIR/sqlline.log" &> /dev/null +TOUCH_EXIT_CODE=$? +if [ "$TOUCH_EXIT_CODE" = "0" ]; then + echo "Drill log directory: $DRILL_LOG_DIR" + DRILL_LOG_DIR_FALLBACK=0 +else + #Force DRILL_LOG_DIR to fall back + DRILL_LOG_DIR_FALLBACK=1 fi -if [ ! -d $DRILL_LOG_DIR ] || [ $DRILL_LOG_DIR_FALLBACK = 1 ]; then +if [ ! -d "$DRILL_LOG_DIR" ] || [ "$DRILL_LOG_DIR_FALLBACK" = "1" ]; then echo "Drill log directory $DRILL_LOG_DIR does not exist or is not writable, defaulting to $DRILL_HOME/log" DRILL_LOG_DIR=$DRILL_HOME/log mkdir -p $DRILL_LOG_DIR