Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B152E200BA7 for ; Fri, 21 Oct 2016 23:46:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id AFADC160AE8; Fri, 21 Oct 2016 21:46:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 01CC3160ADE for ; Fri, 21 Oct 2016 23:46:51 +0200 (CEST) Received: (qmail 42379 invoked by uid 500); 21 Oct 2016 21:46:51 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 42362 invoked by uid 99); 21 Oct 2016 21:46:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Oct 2016 21:46:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B236FE00B3; Fri, 21 Oct 2016 21:46:50 +0000 (UTC) From: ctubbsii To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #160: ACCUMULO-4490: Simplify Accumulo scripts and con... Content-Type: text/plain Message-Id: <20161021214650.B236FE00B3@git1-us-west.apache.org> Date: Fri, 21 Oct 2016 21:46:50 +0000 (UTC) archived-at: Fri, 21 Oct 2016 21:46:52 -0000 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. ---