Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/547#discussion_r71647434 --- Diff: distribution/src/resources/drill-config.sh --- @@ -50,94 +70,252 @@ home=`cd "$bin/..">/dev/null; pwd` this="$home/bin/$script" # the root of the drill installation -if [ -z "$DRILL_HOME" ]; then - DRILL_HOME="$home" -fi +DRILL_HOME=${DRILL_HOME:-$home} -#check to see if the conf dir or drill home are given as an optional arguments -while [ $# -gt 1 ]; do - if [ "--config" = "$1" ]; then +# Standardize error messages + +fatal_error() { + echo "ERROR: $@" 1>&2 + exit 1 +} + +# Check to see if the conf dir or drill home are given as an optional arguments +# Arguments may appear anywhere on the command line. --site is an alias, better +# specifies that the location contains all site-specific files, not just config. +# +# Remaining arguments go into the args array - use that instead of $@. + +args=() +while [[ $# > 0 ]] +do + arg="$1" + case "$arg" in + --site|--config) shift - confdir=$1 + DRILL_CONF_DIR=$1 shift - DRILL_CONF_DIR=$confdir - else - # Presume we are at end of options and break - break - fi + ;; + *) + args+=("$1") + shift + ;; + esac done +export args + +# If config dir is given, it must exist. + +if [ -n "$DRILL_CONF_DIR" ]; then + if [[ ! -d "$DRILL_CONF_DIR" ]]; then + fatal_error "Config dir does not exist:" $DRILL_CONF_DIR + fi +else -# Allow alternate drill conf dir location. -DRILL_CONF_DIR="${DRILL_CONF_DIR:-/etc/drill/conf}" + # Allow alternate drill conf dir location. + DRILL_CONF_DIR="/etc/drill/conf" -if [ ! -d $DRILL_CONF_DIR ]; then - DRILL_CONF_DIR=$DRILL_HOME/conf + # Otherwise, use the default + if [[ ! -d "$DRILL_CONF_DIR" ]]; then + DRILL_CONF_DIR="$DRILL_HOME/conf" + fi +fi + +# However we got the config dir, it must contain a config +# file, and that file must be readable. +# Most files are optional, so check the one that is required: +# drill-override.conf. + +testFile="$DRILL_CONF_DIR/drill-override.conf" +if [[ ! -a "$testFile" ]]; then + fatal_error "Drill config file missing: $testFile -- Wrong config dir?" +fi +if [[ ! -r "$testFile" ]]; then + fatal_error "Drill config file not readable: $testFile - Wrong user?" +fi + +# Set Drill-provided defaults here. Do not put Drill defaults --- End diff -- Glad to do so, but is it necessary? The comment at the top says: # Variables may be set in one of four places: # # Environment (per run) # drill-env.sh (per site) # distrib-env.sh (per distribution) # drill-config.sh (this file, Drill defaults) Seems that the description of what goes into each file tells the tale. However, if the terse comments were unclear, I can certainly revise them to add a bit more background.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---