accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubbsii <...@git.apache.org>
Subject [GitHub] accumulo pull request #160: ACCUMULO-4490: Simplify Accumulo scripts and con...
Date Fri, 21 Oct 2016 21:46:50 GMT
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/160#discussion_r84550189
  
    --- Diff: assemble/scripts/load-env.sh ---
    @@ -0,0 +1,153 @@
    +#! /usr/bin/env bash
    +
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +
    +# Sources accumulo-env.sh and verifies environment variables
    +
    +function verify_env_dir() {
    +  property=$1
    +  directory=$2
    +  if [[ -z "$directory" ]]; then
    +    echo "$property is not set. Please make sure it's set globally or in conf/accumulo-env.sh."
    +    exit 1
    +  fi
    +  if [[ ! -d "$directory" ]]; then
    +    echo "$property=$directory is not a valid directory. Please make sure it's set correctly
globally or in conf/accumulo-env.sh."
    +    exit 1
    +  fi
    +}
    +
    +# Resolve a program to its installation directory
    +locationByProgram()
    +{
    +   RESULT=$( which "$1" )
    +   if [[ "$?" != 0 && -z "${RESULT}" ]]; then
    +      echo "Cannot find '$1' and '$2' is not set in $ACCUMULO_CONF_DIR/accumulo-env.sh"
    +      exit 1
    +   fi
    +   while [ -h "${RESULT}" ]; do # resolve $RESULT until the file is no longer a symlink
    +      DIR="$( cd -P "$( dirname "$RESULT" )" && pwd )"
    +      RESULT="$(readlink "${RESULT}")"
    +      [[ "${RESULT}" != /* ]] && RESULT="${DIR}/${RESULT}" # if $RESULT was a
relative symlink, we need to resolve it relative to the path where the symlink file was located
    +   done
    +   # find the relative home directory, accounting for an extra bin directory
    +   RESULT=$(dirname "$(dirname "${RESULT}")")
    +   echo "Auto-set ${2} to '${RESULT}'.  To suppress this message, set ${2} in conf/accumulo-env.sh"
    +   eval "${2}=${RESULT}"
    +}
    +
    +# Resolve base directory
    +SOURCE="${BASH_SOURCE[0]}"
    +while [ -h "$SOURCE" ]; do
    +   scripts="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
    +   SOURCE="$(readlink "$SOURCE")"
    +   [[ $SOURCE != /* ]] && SOURCE="$scripts/$SOURCE"
    +done
    +scripts="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
    +basedir=$( cd -P "${scripts}"/../.. && pwd )
    +
    +export ACCUMULO_CONF_DIR="${ACCUMULO_CONF_DIR:-$basedir/conf}"
    +
    +if [[ -z $ACCUMULO_CONF_DIR || ! -d $ACCUMULO_CONF_DIR ]]; then
    +  echo "ACCUMULO_CONF_DIR=$ACCUMULO_CONF_DIR is not a valid directory.  Please make sure
it exists"
    +  exit 1
    +fi
    +
    +if [[ ! -f $ACCUMULO_CONF_DIR/accumulo-env.sh || ! -f $ACCUMULO_CONF_DIR/accumulo-site.xml
]]; then
    +  echo "The configuration files 'accumulo-env.sh' & 'accumulo-site.xml' must exist
in $ACCUMULO_CONF_DIR"
    +  echo "Run 'accumulo config' to create them or copy them from $ACCUMULO_CONF_DIR/examples"
    +  echo "Follow the instructions in INSTALL.md to edit them for your environment."
    +  exit 1
    +fi
    +
    +source "$ACCUMULO_CONF_DIR/accumulo-env.sh"
    +
    +## Variables that must be set
    +
    +: "${ACCUMULO_TSERVER_OPTS:?"ACCUMULO_TSERVER_OPTS is not set in accumulo-env.sh"}"
    --- End diff --
    
    Yes, it is. But, bash also prefixes the message with the name of the variable, so having
that in the message is a bit redundant.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message