Author: ecn Date: Fri Mar 1 16:54:02 2013 New Revision: 1451647 URL: http://svn.apache.org/r1451647 Log: ACCUMULO-1071 committing Damon Brown's patch to clean-up the shell scripts
Added: accumulo/trunk/bin/bootstrap_config.sh (with props) Modified: accumulo/trunk/ (props changed) accumulo/trunk/assemble/ (props changed) accumulo/trunk/bin/LogForwarder.sh accumulo/trunk/bin/accumulo accumulo/trunk/bin/bootstrap_hdfs.sh accumulo/trunk/bin/config.sh accumulo/trunk/bin/etc_initd_accumulo accumulo/trunk/bin/generate_monitor_certificate.sh accumulo/trunk/bin/start-all.sh accumulo/trunk/bin/start-here.sh accumulo/trunk/bin/start-server.sh accumulo/trunk/bin/stop-all.sh accumulo/trunk/bin/stop-here.sh accumulo/trunk/bin/stop-server.sh accumulo/trunk/bin/tdown.sh accumulo/trunk/bin/tool.sh accumulo/trunk/bin/tup.sh accumulo/trunk/core/ (props changed) accumulo/trunk/examples/ (props changed) accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java (props changed) accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java (props changed) accumulo/trunk/server/ (props changed) accumulo/trunk/src/ (props changed) Propchange: accumulo/trunk/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5:r1451640 Propchange: accumulo/trunk/assemble/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/assemble:r1451640 Modified: accumulo/trunk/bin/LogForwarder.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/LogForwarder.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/LogForwarder.sh (original) +++ accumulo/trunk/bin/LogForwarder.sh Fri Mar 1 16:54:02 2013 @@ -33,6 +33,18 @@ # # LogForwarder.sh -h 127.0.0.1 -p 4448 -f tserver* -s 2010010100001 -e 20100101235959 -l INFO -m .*scan.* # -. accumulo-config.sh -java -cp $ACCUMULO_HOME/lib org.apache.accumulo.server.util.SendLogToChainsaw -d $ACCUMULO_LOG_DIR "$@" +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +script=$( basename "$SOURCE" ) +# Stop: Resolve Script Directory + +. "$bin"/config.sh + +${JAVA_HOME}/bin/java -cp $ACCUMULO_HOME/lib org.apache.accumulo.server.util.SendLogToChainsaw -d $ACCUMULO_LOG_DIR "$@" Modified: accumulo/trunk/bin/accumulo URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/accumulo?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/accumulo (original) +++ accumulo/trunk/bin/accumulo Fri Mar 1 16:54:02 2013 @@ -15,116 +15,107 @@ # See the License for the specific language governing permissions and # limitations under the License. -_readlink () -{ - result=`readlink -f $1 2>/dev/null` - if [ $? -eq 0 ]; - then - echo $result - return 0 - fi - - oldPath=$1 - if [ -n `echo $oldPath | egrep "^[.]"` ]; then - oldPath=`echo $1 | sed -e 's#[.]/##'` - fi - if [ -z `echo $oldPath | egrep '^/'` ]; then - oldPath="`pwd`/$oldPath" - fi - newPath=$oldPath - while [ "$newPath" ]; - do - oldPath=$newPath - newPath=`readlink $newPath` - done - - echo $oldPath - return 0 -} - -bin=`_readlink $0` -bin=`dirname "$bin"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +script=$( basename "$SOURCE" ) +# Stop: Resolve Script Directory . "$bin"/config.sh START_JAR=$ACCUMULO_HOME/lib/accumulo-start-$ACCUMULO_VERSION.jar:$ACCUMULO_HOME/lib/log4j-1.2.16.jar +# +# Resolve a program to its installation directory +# locationByProgram() { - # find the program - RESULT=`which $1 2>/dev/null` - if test ! -z "$RESULT" - then - # strip the program name from the path - RESULT=`dirname ${RESULT}` - # strip /bin from the path - RESULT=`dirname ${RESULT}` - echo ${RESULT} + RESULT=$( which "$1" ) + if [[ "$?" != 0 && -z "$RESULT" ]]; then + echo "Cannot find '$1' and '$2' is not set in conf/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 + RESULT=$(dirname ${RESULT}) + echo "Auto-set ${2} to '${RESULT}'. To suppress this message, set ${2} in conf/accumulo-env.sh" + eval "${2}=${RESULT}" } -test -n "$JAVA_HOME" || export JAVA_HOME=`locationByProgram java` -test -n "$HADOOP_PREFIX" || export HADOOP_PREFIX=`locationByProgram hadoop` -test -n "$ZOOKEEPER_HOME" || export ZOOKEEPER_HOME=`locationByProgram zkCli.sh` - +test -z "$JAVA_HOME" && locationByProgram java JAVA_HOME +test -z "$HADOOP_PREFIX" && locationByProgram hadoop HADOOP_PREFIX +test -z "$ZOOKEEPER_HOME" && locationByProgram zkCli.sh ZOOKEEPER_HOME DEFAULT_GENERAL_JAVA_OPTS="" +# # ACCUMULO_XTRAJARS is where all of the commandline -add items go into for reading by accumulo. +# if [ "$1" = "-add" ] ; then - export ACCUMULO_XTRAJARS=$2 - shift 2 + export ACCUMULO_XTRAJARS=$2 + shift 2 else - export ACCUMULO_XTRAJARS="" + export ACCUMULO_XTRAJARS="" fi -if [ "$1" = "master" ] ; then - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_MASTER_OPTS}" -elif [ "$1" = "gc" ] ; then - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_GC_OPTS}" -elif [ "$1" = "tserver" ] ; then - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_TSERVER_OPTS}" -elif [ "$1" = "monitor" ] ; then - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_MONITOR_OPTS}" -elif [ "$1" = "logger" ] ; then - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_LOGGER_OPTS}" -else - export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_OTHER_OPTS}" -fi +# +# Add appropriate options for process type +# +case "$1" in +master) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_MASTER_OPTS}" ;; +gc) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_GC_OPTS}" ;; +tserver) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_TSERVER_OPTS}" ;; +monitor) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_MONITOR_OPTS}" ;; +logger) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_LOGGER_OPTS}" ;; +*) export ACCUMULO_OPTS="${ACCUMULO_GENERAL_OPTS} ${ACCUMULO_OTHER_OPTS}" ;; +esac XML_FILES=${ACCUMULO_HOME}/conf CLASSPATH=${XML_FILES}:${START_JAR} -if [ -z $JAVA_HOME -o ! -d $JAVA_HOME ]; then - echo "JAVA_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 -fi -if [ -z $HADOOP_PREFIX -o ! -d $HADOOP_PREFIX ]; then - echo "HADOOP_PREFIX is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 -fi -if [ -z $ZOOKEEPER_HOME -o ! -d $ZOOKEEPER_HOME ]; then - echo "ZOOKEEPER_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 -fi -if [ -z $ACCUMULO_LOG_DIR ]; then - echo "ACCUMULO_LOG_DIR is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 +if [ -z "$JAVA_HOME" -o ! -d "$JAVA_HOME" ]; then + echo "JAVA_HOME is not set or is not a directory. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 +fi +if [ -z "$HADOOP_PREFIX" -o ! -d "$HADOOP_PREFIX" ]; then + echo "HADOOP_PREFIX is not set or is not a directory. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 +fi +if [ -z "$ZOOKEEPER_HOME" -o ! -d "$ZOOKEEPER_HOME" ]; then + echo "ZOOKEEPER_HOME is not set or is not a directory. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 +fi +if [ -z "$ACCUMULO_LOG_DIR" ]; then + echo "ACCUMULO_LOG_DIR is not set. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 fi if [ ! -d "$ACCUMULO_LOG_DIR" ]; then - mkdir -p $ACCUMULO_LOG_DIR; + mkdir -p "$ACCUMULO_LOG_DIR" fi -#Export the variables just in case they are not exported -#This makes them available to java -export JAVA_HOME=$JAVA_HOME -export HADOOP_PREFIX=$HADOOP_PREFIX -export ZOOKEEPER_HOME=$ZOOKEEPER_HOME - -JAVA=$JAVA_HOME/bin/java -PLATFORM="`$JAVA -cp $CLASSPATH org.apache.accumulo.start.Platform`" +# Export the variables just in case they are not exported +# This makes them available to java +export JAVA_HOME HADOOP_PREFIX ZOOKEEPER_HOME +JAVA="$JAVA_HOME/bin/java" +PLATFORM=$( $JAVA -cp $CLASSPATH org.apache.accumulo.start.Platform ) +# # app isn't used anywhere, but it makes the process easier to spot when ps/top/snmp truncate the command line -exec $JAVA "-Dapp=$1" $ACCUMULO_OPTS -classpath $CLASSPATH -XX:OnOutOfMemoryError="kill -9 %p" -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl -Djava.library.path="$HADOOP_PREFIX/lib/native/$PLATFORM" -Dorg.apache.accumulo.core.home.dir="$ACCUMULO_HOME" -Dhadoop.home.dir="$HADOOP_PREFIX" -Dzookeeper.home.dir="$ZOOKEEPER_HOME" org.apache.accumulo.start.Main "$@" +exec $JAVA "-Dapp=$1" $ACCUMULO_OPTS -classpath $CLASSPATH -XX:OnOutOfMemoryError="kill -9 %p" \ + -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl \ + -Djava.library.path="$HADOOP_PREFIX/lib/native/$PLATFORM" \ + -Dorg.apache.accumulo.core.home.dir="$ACCUMULO_HOME" \ + -Dhadoop.home.dir="$HADOOP_PREFIX" \ + -Dzookeeper.home.dir="$ZOOKEEPER_HOME" \ + org.apache.accumulo.start.Main \ + "$@" Added: accumulo/trunk/bin/bootstrap_config.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/bootstrap_config.sh?rev=1451647&view=auto ============================================================================== --- accumulo/trunk/bin/bootstrap_config.sh (added) +++ accumulo/trunk/bin/bootstrap_config.sh Fri Mar 1 16:54:02 2013 @@ -0,0 +1,74 @@ +#! /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. + +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory + +# +# Resolve accumulo home for bootstrapping +# +ACCUMULO_HOME=$( cd -P ${bin}/.. && pwd ) + +SIZE="" +TYPE="" +if [ -n "$1" ]; then + SIZE=$1 + TYPE="standalone" +fi + +if [ "$2" = "native" ]; then + TYPE="native-standalone" +fi + +if [ -z "${SIZE}" ]; then + echo "Choose the heap configuration:" + select DIRNAME in $(cd ${ACCUMULO_HOME}/conf/examples && ls -d */standalone/.. | sed -e 's/\/.*//'); do + echo "Using '${DIRNAME}' configuration" + SIZE=${DIRNAME} + break + done +fi + +if [ -z "${TYPE}" ]; then + echo + echo "Choose the hadoop library type:" + select TYPENAME in Java Native; do + if [ "${TYPENAME}" = "native" ]; then + TYPE="native-standalone" + else + TYPE="standalone" + fi + echo "Using '${TYPE}' configuration" + echo + break + done +fi + +CONF_DIR="${ACCUMULO_HOME}/conf/examples/${SIZE}/${TYPE}" + +echo "Initializing default configuration from '${CONF_DIR}'" +# +# Perform a copy with update here to not overwrite existing files +# +cp -vu ${CONF_DIR}/* ${ACCUMULO_HOME}/conf Propchange: accumulo/trunk/bin/bootstrap_config.sh ------------------------------------------------------------------------------ svn:eol-style = native Modified: accumulo/trunk/bin/bootstrap_hdfs.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/bootstrap_hdfs.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/bootstrap_hdfs.sh (original) +++ accumulo/trunk/bin/bootstrap_hdfs.sh Fri Mar 1 16:54:02 2013 @@ -15,27 +15,33 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh # # Find the system context directory in HDFS # -SYSTEM_CONTEXT_HDFS_DIR=`grep -A1 "general.vfs.classpaths" "$ACCUMULO_HOME/conf/accumulo-site.xml" | tail -1 | perl -pe 's/\s+<value>//; s/<\/value>//; print $ARGV[1]'` - -if [ -z "$SYSTEM_CONTEXT_HDFS_DIR" ]; then +SYSTEM_CONTEXT_HDFS_DIR=$(grep -A1 "general.vfs.classpaths" "$ACCUMULO_HOME/conf/accumulo-site.xml" | tail -1 | perl -pe 's/\s+<value>//; s/<\/value>//; print $ARGV[1]') - echo "Your accumulo-site.xml file is not set up for the HDFS Classloader. Please add the following to your accumulo-site.xml file:" - echo "" - echo "<property>" - echo " <name>general.vfs.classpaths</name>" - echo " <value>hdfs://host:port/dir</value>" - echo " <description>location of the jars for the default (system) context</description>" - echo "</property>" - exit +if [ -z "$SYSTEM_CONTEXT_HDFS_DIR" ] +then + echo "Your accumulo-site.xml file is not set up for the HDFS Classloader. Please add the following to your accumulo-site.xml file:" + echo "" + echo "<property>" + echo " <name>general.vfs.classpaths</name>" + echo " <value>hdfs://host:port/dir</value>" + echo " <description>location of the jars for the default (system) context</description>" + echo "</property>" + exit 1 fi # @@ -43,29 +49,28 @@ fi # "$HADOOP_PREFIX/bin/hadoop" fs -ls "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null if [ $? -ne 0 ]; then - "$HADOOP_PREFIX/bin/hadoop" fs -mkdir "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null + "$HADOOP_PREFIX/bin/hadoop" fs -mkdir "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null fi # # Replicate to all slaves to avoid network contention on startup # -NUM_SLAVES=`wc -l $ACCUMULO_HOME/conf/slaves | grep -P '^\d+(?= )' -o` +SLAVES="$ACCUMULO_HOME/conf/slaves" +NUM_SLAVES=$(egrep -v '(^#|^\s*$)' "$SLAVES" | wc -l) #let each datanode service around 50 clients let "REP=$NUM_SLAVES/50" if [ $REP -lt 3 ]; then - REP=3 + REP=3 fi # # Copy all jars in lib to the system context directory # "$HADOOP_PREFIX/bin/hadoop" fs -moveFromLocal "$ACCUMULO_HOME"/lib/*.jar "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null - "$HADOOP_PREFIX/bin/hadoop" fs -setrep -R $REP "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null - # # We need two of the jars in lib, copy them back out and remove them from the system context dir # Modified: accumulo/trunk/bin/config.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/config.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/config.sh (original) +++ accumulo/trunk/bin/config.sh Fri Mar 1 16:54:02 2013 @@ -15,30 +15,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -this="$0" -while [ -h "$this" ]; do - ls=`ls -ld "$this"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then - this="$link" - else - this=`dirname "$this"`/"$link" - fi +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done -bin=`dirname "$this"` -script=`basename "$this"` -bin=`cd "$bin"; pwd` -this="$bin/$script" +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +script=$( basename "$SOURCE" ) +# Stop: Resolve Script Directory -ACCUMULO_HOME=`dirname "$this"`/.. -export ACCUMULO_HOME=`cd $ACCUMULO_HOME; pwd` +ACCUMULO_HOME=$( cd -P ${bin}/.. && pwd ) +export ACCUMULO_HOME if [ -f $ACCUMULO_HOME/conf/accumulo-env.sh ] ; then -. $ACCUMULO_HOME/conf/accumulo-env.sh + . $ACCUMULO_HOME/conf/accumulo-env.sh +else + # + # Attempt to bootstrap configuration and continue + # + echo "" + echo "Accumulo is not properly configured." + echo "Please choose from the following example configurations..." + echo "" + $ACCUMULO_HOME/bin/bootstrap_config.sh + [[ $? != 0 ]] && echo "Bootstrap canceled, exiting..." && exit 1 + . $ACCUMULO_HOME/conf/accumulo-env.sh fi if [ -z ${ACCUMULO_LOG_DIR} ]; then - ACCUMULO_LOG_DIR=$ACCUMULO_HOME/logs + ACCUMULO_LOG_DIR=$ACCUMULO_HOME/logs fi mkdir -p $ACCUMULO_LOG_DIR 2>/dev/null @@ -46,7 +53,7 @@ mkdir -p $ACCUMULO_LOG_DIR 2>/dev/null export ACCUMULO_LOG_DIR if [ -z "${ACCUMULO_VERSION}" ]; then - ACCUMULO_VERSION=1.6.0-SNAPSHOT + ACCUMULO_VERSION=1.6.0-SNAPSHOT fi if [ -z "$HADOOP_PREFIX" ] @@ -62,52 +69,49 @@ then fi if [ ! -d "$HADOOP_PREFIX" ] then - echo "$HADOOP_PREFIX is not a directory" - exit 1 + echo "$HADOOP_PREFIX is not a directory" + exit 1 fi export HADOOP_PREFIX -if [ ! -f "$ACCUMULO_HOME/conf/masters" -o ! -f "$ACCUMULO_HOME/conf/slaves" ] -then - if [ ! -f "$ACCUMULO_HOME/conf/masters" -a ! -f "$ACCUMULO_HOME/conf/slaves" ] - then - echo "STANDALONE: Missing both conf/masters and conf/slaves files" - echo "STANDALONE: Assuming single-node (localhost only) instance" - echo "STANDALONE: echo "`hostname`" > $ACCUMULO_HOME/conf/masters" - echo `hostname` > "$ACCUMULO_HOME/conf/masters" - echo "STANDALONE: echo "`hostname`" > $ACCUMULO_HOME/conf/slaves" - echo `hostname` > "$ACCUMULO_HOME/conf/slaves" - fgrep -s logger.dir.walog "$ACCUMULO_HOME/conf/accumulo-site.xml" > /dev/null - WALOG_CONFIGURED=$? - if [ $WALOG_CONFIGURED -ne 0 -a ! -e "$ACCUMULO_HOME/walogs" ] - then - echo "STANDALONE: Creating default local write-ahead log directory" - mkdir "$ACCUMULO_HOME/walogs" - echo "STANDALONE: mkdir \"$ACCUMULO_HOME/walogs\"" - fi - if [ ! -e "$ACCUMULO_HOME/conf/accumulo-metrics.xml" ] - then - echo "STANDALONE: Creating default metrics configuration" - cp "$ACCUMULO_HOME/conf/accumulo-metrics.xml.example" "$ACCUMULO_HOME/conf/accumulo-metrics.xml" - fi - else - echo "You are missing either $ACCUMULO_HOME/conf/masters or $ACCUMULO_HOME/conf/slaves" - echo "Please configure them both for a multi-node instance, or delete them both for a single-node (localhost only) instance" - exit 1 - fi +if [ ! -f "$ACCUMULO_HOME/conf/masters" -o ! -f "$ACCUMULO_HOME/conf/slaves" ]; then + if [ ! -f "$ACCUMULO_HOME/conf/masters" -a ! -f "$ACCUMULO_HOME/conf/slaves" ]; then + echo "STANDALONE: Missing both conf/masters and conf/slaves files" + echo "STANDALONE: Assuming single-node (localhost only) instance" + echo "STANDALONE: echo "`hostname`" > $ACCUMULO_HOME/conf/masters" + echo `hostname` > "$ACCUMULO_HOME/conf/masters" + echo "STANDALONE: echo "`hostname`" > $ACCUMULO_HOME/conf/slaves" + echo `hostname` > "$ACCUMULO_HOME/conf/slaves" + fgrep -s logger.dir.walog "$ACCUMULO_HOME/conf/accumulo-site.xml" > /dev/null + WALOG_CONFIGURED=$? + if [ $WALOG_CONFIGURED -ne 0 -a ! -e "$ACCUMULO_HOME/walogs" ]; then + echo "STANDALONE: Creating default local write-ahead log directory" + mkdir "$ACCUMULO_HOME/walogs" + echo "STANDALONE: mkdir \"$ACCUMULO_HOME/walogs\"" + fi + if [ ! -e "$ACCUMULO_HOME/conf/accumulo-metrics.xml" ]; then + echo "STANDALONE: Creating default metrics configuration" + cp "$ACCUMULO_HOME/conf/accumulo-metrics.xml.example" "$ACCUMULO_HOME/conf/accumulo-metrics.xml" + fi + else + echo "You are missing either $ACCUMULO_HOME/conf/masters or $ACCUMULO_HOME/conf/slaves" + echo "Please configure them both for a multi-node instance, or delete them both for a single-node (localhost only) instance" + exit 1 + fi fi -MASTER1=`grep -v '^#' "$ACCUMULO_HOME/conf/masters" | head -1` +MASTER1=$(egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/masters" | head -1) GC=$MASTER1 MONITOR=$MASTER1 if [ -f "$ACCUMULO_HOME/conf/gc" ]; then - GC=`grep -v '^#' "$ACCUMULO_HOME/conf/gc" | head -1` + GC=$(egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/gc" | head -1) fi if [ -f "$ACCUMULO_HOME/conf/monitor" ]; then - MONITOR=`grep -v '^#' "$ACCUMULO_HOME/conf/monitor" | head -1` + MONITOR=$(egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/monitor" | head -1) fi if [ ! -f "$ACCUMULO_HOME/conf/tracers" ]; then - echo "$MASTER1" > "$ACCUMULO_HOME/conf/tracers" + echo "$MASTER1" > "$ACCUMULO_HOME/conf/tracers" fi + SSH='ssh -qnf -o ConnectTimeout=2' export HADOOP_HOME=$HADOOP_PREFIX Modified: accumulo/trunk/bin/etc_initd_accumulo URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/etc_initd_accumulo?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/etc_initd_accumulo (original) +++ accumulo/trunk/bin/etc_initd_accumulo Fri Mar 1 16:54:02 2013 @@ -32,20 +32,20 @@ ACCUMULO_HOME=`cd $pwd/.. ; pwd -P` RETVAL=0 case "$1" in start) - $ACCUMULO_HOME/bin/start-here.sh - RETVAL=$? + $ACCUMULO_HOME/bin/start-here.sh + RETVAL=$? ;; stop) - $ACCUMULO_HOME/bin/stop-here.sh - RETVAL=$? + $ACCUMULO_HOME/bin/stop-here.sh + RETVAL=$? ;; status) - COUNT=`pgrep -f "$ACCUMULO_HOME.*org.apache.accumulo.start" | wc -l` - echo "There are $COUNT accumulo processes on this machine" + COUNT=$(pgrep -f "$ACCUMULO_HOME.*org.apache.accumulo.start" | wc -l) + echo "There are $COUNT accumulo processes on this machine" ;; restart) - $0 stop - $0 start + $0 stop + $0 start ;; *) echo "Usage: $0 {start|stop|status|restart}" Modified: accumulo/trunk/bin/generate_monitor_certificate.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/generate_monitor_certificate.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/generate_monitor_certificate.sh (original) +++ accumulo/trunk/bin/generate_monitor_certificate.sh Fri Mar 1 16:54:02 2013 @@ -15,45 +15,52 @@ # See the License for the specific language governing permissions and # limitations under the License. -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh ALIAS="default" -KEYPASS=`cat /dev/random | head -c33 | uuencode -m foo | head -2 | tail +2` -STOREPASS=`cat /dev/random | head -c33 | uuencode -m foo | head -2 | tail +2` +KEYPASS=$(cat /dev/random | head -c33 | uuencode -m foo | head -2 | tail +2) +STOREPASS=$(cat /dev/random | head -c33 | uuencode -m foo | head -2 | tail +2) KEYSTOREPATH="$ACCUMULO_HOME/conf/keystore.jks" TRUSTSTOREPATH="$ACCUMULO_HOME/conf/cacerts.jks" CERTPATH="$ACCUMULO_HOME/conf/server.cer" -if [ -e "$KEYSTOREPATH" ] ; then - rm -i $KEYSTOREPATH - if [ -e "$KEYSTOREPATH" ] ; then - echo "keystore already exists, exiting" - exit 1 - fi +if [ -e "$KEYSTOREPATH" ]; then + rm -i $KEYSTOREPATH + if [ -e "$KEYSTOREPATH" ]; then + echo "KeyStore already exists, exiting" + exit 1 + fi fi -if [ -e "$TRUSTSTOREPATH" ] ; then - rm -i $TRUSTSTOREPATH - if [ -e "$TRUSTSTOREPATH" ] ; then - echo "truststore already exists, exiting" - exit 2 - fi +if [ -e "$TRUSTSTOREPATH" ]; then + rm -i $TRUSTSTOREPATH + if [ -e "$TRUSTSTOREPATH" ]; then + echo "TrustStore already exists, exiting" + exit 2 + fi fi -if [ -e "$CERTPATH" ] ; then - rm -i $CERTPATH - if [ -e "$CERTPATH" ] ; then - echo "cert already exists, exiting" - exit 3 +if [ -e "$CERTPATH" ]; then + rm -i $CERTPATH + if [ -e "$CERTPATH" ]; then + echo "Certificate already exists, exiting" + exit 3 fi fi -keytool -genkey -alias $ALIAS -keyalg RSA -keypass $KEYPASS -storepass $STOREPASS -keystore $KEYSTOREPATH -keytool -export -alias $ALIAS -storepass $STOREPASS -file $CERTPATH -keystore $KEYSTOREPATH -echo "yes" | keytool -import -v -trustcacerts -alias $ALIAS -file $CERTPATH -keystore $TRUSTSTOREPATH -keypass $KEYPASS -storepass $STOREPASS +${JAVA_HOME}/bin/keytool -genkey -alias $ALIAS -keyalg RSA -keypass $KEYPASS -storepass $STOREPASS -keystore $KEYSTOREPATH +${JAVA_HOME}/bin/keytool -export -alias $ALIAS -storepass $STOREPASS -file $CERTPATH -keystore $KEYSTOREPATH +echo "yes" | ${JAVA_HOME}/bin/keytool -import -v -trustcacerts -alias $ALIAS -file $CERTPATH -keystore $TRUSTSTOREPATH -keypass $KEYPASS -storepass $STOREPASS echo echo "keystore and truststore generated. now add the following to accumulo-site.xml:" Modified: accumulo/trunk/bin/start-all.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/start-all.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/start-all.sh (original) +++ accumulo/trunk/bin/start-all.sh Fri Mar 1 16:54:02 2013 @@ -15,49 +15,51 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh unset DISPLAY if [ ! -f $ACCUMULO_HOME/conf/accumulo-env.sh ] ; then - echo "${ACCUMULO_HOME}/conf/accumulo-env.sh does not exist. Please make sure you configure Accumulo before you run anything" - echo "We provide examples you can copy in ${ACCUMULO_HOME}/conf/examples/ which are set up for your memory footprint" - exit 1 + echo "${ACCUMULO_HOME}/conf/accumulo-env.sh does not exist. Please make sure you configure Accumulo before you run anything" + echo "We provide examples you can copy in ${ACCUMULO_HOME}/conf/examples/ which are set up for your memory footprint" + exit 1 fi - if [ -z "$ZOOKEEPER_HOME" ] ; then - echo "ZOOKEEPER_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 + echo "ZOOKEEPER_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 fi -ZOOKEEPER_VERSION=`(cd $ZOOKEEPER_HOME; ls zookeeper-[0-9]*.jar | head -1)` +ZOOKEEPER_VERSION=$(cd $ZOOKEEPER_HOME && ls zookeeper-[0-9]*.jar | head -1) ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION/zookeeper-/} ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION/.jar/} -if [ "$ZOOKEEPER_VERSION" '<' "3.3.0" ] ; then - echo "WARN : Using Zookeeper $ZOOKEEPER_VERSION. Use version 3.3.0 or greater to avoid zookeeper deadlock bug."; +if [ "$ZOOKEEPER_VERSION" '<' "3.3.0" ]; then + echo "WARN : Using Zookeeper $ZOOKEEPER_VERSION. Use version 3.3.0 or greater to avoid zookeeper deadlock bug."; fi ${bin}/start-server.sh $MONITOR monitor -if [ "$1" != "--notSlaves" ] ; then - ${bin}/tup.sh +if [ "$1" != "--notSlaves" ]; then + ${bin}/tup.sh fi ${bin}/accumulo org.apache.accumulo.server.master.state.SetGoalState NORMAL -for master in `grep -v '^#' "$ACCUMULO_HOME/conf/masters"` -do - ${bin}/start-server.sh $master master +for master in `egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/masters"`; do + ${bin}/start-server.sh $master master done ${bin}/start-server.sh $GC gc "garbage collector" - -for tracer in `grep -v '^#' "$ACCUMULO_HOME/conf/tracers"` -do +for tracer in `egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/tracers"`; do ${bin}/start-server.sh $tracer tracer done Modified: accumulo/trunk/bin/start-here.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/start-here.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/start-here.sh (original) +++ accumulo/trunk/bin/start-here.sh Fri Mar 1 16:54:02 2013 @@ -19,65 +19,60 @@ # This script starts all the accumulo services on this host # -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh IFCONFIG=/sbin/ifconfig -if [ ! -x $IFCONFIG ] -then +if [ ! -x $IFCONFIG ]; then IFCONFIG='/bin/netstat -ie' fi -ip=`$IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1` -if [ $? != 0 ] -then - ip=`python -c 'import socket as s; print s.gethostbyname(s.getfqdn())'` +ip=$($IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1) +if [ $? != 0 ]; then + ip=$(python -c 'import socket as s; print s.gethostbyname(s.getfqdn())') fi HOSTS="`hostname -a` `hostname` localhost 127.0.0.1 $ip" -for host in $HOSTS -do - if grep -q "^${host}\$" $ACCUMULO_HOME/conf/slaves - then - ${bin}/start-server.sh $host tserver "tablet server" - break - fi -done - -for host in $HOSTS -do - if grep -q "^${host}\$" $ACCUMULO_HOME/conf/masters - then - ${bin}/accumulo org.apache.accumulo.server.master.state.SetGoalState NORMAL - ${bin}/start-server.sh $host master - break - fi -done - -for host in $HOSTS -do - if [ ${host} = "${GC}" ] - then - ${bin}/start-server.sh $GC gc "garbage collector" - break - fi -done - -for host in $HOSTS -do - if [ ${host} = "${MONITOR}" ] - then - ${bin}/start-server.sh $MONITOR monitor - break - fi -done - -for host in $HOSTS -do - if grep -q "^${host}\$" $ACCUMULO_HOME/conf/tracers - then - ${bin}/start-server.sh $host tracer - break - fi +for host in $HOSTS; do + if grep -q "^${host}\$" $ACCUMULO_HOME/conf/slaves; then + ${bin}/start-server.sh $host tserver "tablet server" + break + fi +done + +for host in $HOSTS; do + if grep -q "^${host}\$" $ACCUMULO_HOME/conf/masters; then + ${bin}/accumulo org.apache.accumulo.server.master.state.SetGoalState NORMAL + ${bin}/start-server.sh $host master + break + fi +done + +for host in $HOSTS; do + if [ ${host} = "${GC}" ]; then + ${bin}/start-server.sh $GC gc "garbage collector" + break + fi +done + +for host in $HOSTS; do + if [ ${host} = "${MONITOR}" ]; then + ${bin}/start-server.sh $MONITOR monitor + break + fi +done + +for host in $HOSTS; do + if grep -q "^${host}\$" $ACCUMULO_HOME/conf/tracers; then + ${bin}/start-server.sh $host tracer + break + fi done Modified: accumulo/trunk/bin/start-server.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/start-server.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/start-server.sh (original) +++ accumulo/trunk/bin/start-server.sh Fri Mar 1 16:54:02 2013 @@ -15,62 +15,65 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +script=$( basename "$SOURCE" ) +# Stop: Resolve Script Directory . "$bin"/config.sh -HOST=$1 -host $1 >/dev/null 2>/dev/null -if [ $? -ne 0 ] -then - LOGHOST=$1 +HOST="$1" +host "$1" >/dev/null 2>/dev/null +if [ $? -ne 0 ]; then + LOGHOST="$1" else - LOGHOST="`host $1 | head -1 | cut -d' ' -f1`" + LOGHOST=$(host "$1" | head -1 | cut -d' ' -f1) fi SERVICE="$2" LONGNAME="$3" -if [ -z "$LONGNAME" ] -then +if [ -z "$LONGNAME" ]; then LONGNAME="$2" fi -SLAVES=`wc -l < ${ACCUMULO_HOME}/conf/slaves` +SLAVES=$( wc -l < ${ACCUMULO_HOME}/conf/slaves ) IFCONFIG=/sbin/ifconfig -if [ ! -x $IFCONFIG ] -then +if [ ! -x $IFCONFIG ]; then IFCONFIG='/bin/netstat -ie' fi -ip=`$IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1` + +ip=$($IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1) if [ $? != 0 ] then - ip=`python -c 'import socket as s; print s.gethostbyname(s.getfqdn())'` + ip=$(python -c 'import socket as s; print s.gethostbyname(s.getfqdn())') fi -if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ] -then - PID=`ps -ef | egrep ${ACCUMULO_HOME}/.*/accumulo.*.jar | grep "Main $SERVICE" | grep -v grep | awk {'print $2'} | head -1` +if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ]; then + PID=$(ps -ef | egrep ${ACCUMULO_HOME}/.*/accumulo.*.jar | grep "Main $SERVICE" | grep -v grep | awk {'print $2'} | head -1) else - PID=`$SSH $HOST ps -ef | egrep ${ACCUMULO_HOME}/.*/accumulo.*.jar | grep "Main $SERVICE" | grep -v grep | awk {'print $2'} | head -1` + PID=$($SSH $HOST ps -ef | egrep ${ACCUMULO_HOME}/.*/accumulo.*.jar | grep "Main $SERVICE" | grep -v grep | awk {'print $2'} | head -1) fi -if [ -z $PID ]; then - echo "Starting $LONGNAME on $HOST" - if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ] - then - ${bin}/accumulo ${SERVICE} --address $1 >${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out 2>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err & - MAX_FILES_OPEN=`bash -c 'ulimit -n'` - else - $SSH $HOST "bash -c 'exec nohup ${bin}/accumulo ${SERVICE} --address $1 >${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out 2>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err' &" - MAX_FILES_OPEN=`$SSH $HOST "bash -c 'ulimit -n'"` - fi - - if [ -n "$MAX_FILES_OPEN" ] && [ -n "$SLAVES" ] ; then - if [ "$SLAVES" -gt 10 ] && [ "$MAX_FILES_OPEN" -lt 65536 ]; then - echo "WARN : Max files open on $HOST is $MAX_FILES_OPEN, recommend 65536" - fi - fi +if [ -z "$PID" ]; then + echo "Starting $LONGNAME on $HOST" + if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ]; then + ${bin}/accumulo ${SERVICE} --address $1 >${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out 2>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err & + MAX_FILES_OPEN=$(ulimit -n) + else + $SSH $HOST "bash -c 'exec nohup ${bin}/accumulo ${SERVICE} --address $1 >${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out 2>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err' &" + MAX_FILES_OPEN=$($SSH $HOST "/usr/bin/env bash -c 'ulimit -n'") + fi + + if [ -n "$MAX_FILES_OPEN" ] && [ -n "$SLAVES" ] ; then + if [ "$SLAVES" -gt 10 ] && [ "$MAX_FILES_OPEN" -lt 65536 ]; then + echo "WARN : Max files open on $HOST is $MAX_FILES_OPEN, recommend 65536" + fi + fi else - echo "$HOST : $LONGNAME already running (${PID})" + echo "$HOST : $LONGNAME already running (${PID})" fi Modified: accumulo/trunk/bin/stop-all.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/stop-all.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/stop-all.sh (original) +++ accumulo/trunk/bin/stop-all.sh Fri Mar 1 16:54:02 2013 @@ -16,29 +16,35 @@ # limitations under the License. -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh +echo "Stopping accumulo services..." ${bin}/accumulo admin "$@" stopAll if [ $? -ne 0 ]; then -echo 'Invalid password or unable to connect to the master' -echo 'Press Ctrl-C to cancel now, or force shutdown in 15 seconds' -sleep 10 + echo "Invalid password or unable to connect to the master" + echo "Press Ctrl-C to cancel now, or force shutdown in 15 seconds" + sleep 10 else -echo 'Accumulo shut down cleanly' + echo "Accumulo shut down cleanly" fi -echo 'Utilities and unresponsive servers will be shut down in 5 seconds' +echo "Utilities and unresponsive servers will be shut down in 5 seconds" sleep 5 #look for master and gc processes not killed by 'admin stopAll' -for signal in TERM KILL -do - for master in `grep -v '^#' "$ACCUMULO_HOME/conf/masters"` - do +for signal in TERM KILL ; do + for master in `grep -v '^#' "$ACCUMULO_HOME/conf/masters"`; do ${bin}/stop-server.sh $master "$ACCUMULO_HOME/.*/accumulo-start.*.jar" master $signal done @@ -46,16 +52,14 @@ do ${bin}/stop-server.sh "$MONITOR" "$ACCUMULO_HOME/.*/accumulo-start.*.jar" monitor $signal - for tracer in `grep -v '^#' "$ACCUMULO_HOME/conf/tracers"` - do + for tracer in `egrep -v '(^#|^\s*$)' "$ACCUMULO_HOME/conf/tracers"`; do ${bin}/stop-server.sh $tracer "$ACCUMULO_HOME/.*/accumulo-start.*.jar" tracer $signal done done - # stop tserver still running ${bin}/tdown.sh -echo 'Cleaning all server entries in zookeeper' +echo "Cleaning all server entries in ZooKeeper" $ACCUMULO_HOME/bin/accumulo org.apache.accumulo.server.util.ZooZap -master -tservers -tracers Modified: accumulo/trunk/bin/stop-here.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/stop-here.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/stop-here.sh (original) +++ accumulo/trunk/bin/stop-here.sh Fri Mar 1 16:54:02 2013 @@ -19,34 +19,36 @@ # This script safely stops all the accumulo services on this host # -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh ACCUMULO="$ACCUMULO_HOME/.*/accumulo-start.*.jar" -if egrep -q localhost\|127.0.0.1 $ACCUMULO_HOME/conf/slaves -then - $bin/accumulo admin stop localhost +if egrep -q localhost\|127.0.0.1 $ACCUMULO_HOME/conf/slaves; then + $bin/accumulo admin stop localhost else - for host in `hostname -a` - do - if grep -q $host $ACCUMULO_HOME/conf/slaves - then - $bin/accumulo admin stop $host - fi - done + for host in `hostname -a`; do + if grep -q ${host} $ACCUMULO_HOME/conf/slaves; then + ${bin}/accumulo admin stop $host + fi + done fi -for signal in TERM KILL -do - for svc in tserver gc master monitor logger tracer - do - PID=`ps -ef | egrep ${ACCUMULO} | grep "Main $svc" | grep -v grep | grep -v stop-here.sh | awk {'print \$2'} | head -1` - if [ ! -z $PID ]; then - echo "stopping $svc on `hostname -a | head -1` with signal $signal" - kill -s ${signal} ${PID} - fi - done +for signal in TERM KILL; do + for svc in tserver gc master monitor logger tracer; do + PID=$(ps -ef | egrep ${ACCUMULO} | grep "Main $svc" | grep -v grep | grep -v stop-here.sh | awk '{print $2}' | head -1) + if [ ! -z $PID ]; then + echo "Stopping ${svc} on `hostname -a | head -1` with signal ${signal}" + kill -s ${signal} ${PID} + fi + done done Modified: accumulo/trunk/bin/stop-server.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/stop-server.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/stop-server.sh (original) +++ accumulo/trunk/bin/stop-server.sh Fri Mar 1 16:54:02 2013 @@ -15,9 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh @@ -28,23 +34,23 @@ if [ ! -x $IFCONFIG ] then IFCONFIG='/bin/netstat -ie' fi -ip=`$IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1` +ip=$($IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1) if [ $? != 0 ] then - ip=`python -c 'import socket as s; print s.gethostbyname(s.getfqdn())'` + ip=$(python -c 'import socket as s; print s.gethostbyname(s.getfqdn())') fi # only stop if there's not one already running if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ]; then - PID=`ps -ef | grep "$ACCUMULO_HOME" | egrep ${2} | grep "Main ${3}" | grep -v grep | grep -v ssh | grep -v stop-server.sh | awk {'print \$2'} | head -1` - if [ ! -z $PID ]; then - echo "stopping ${3} on $1"; - kill -s ${4} ${PID} 2>/dev/null - fi; + PID=$(ps -ef | grep "$ACCUMULO_HOME" | egrep ${2} | grep "Main ${3}" | grep -v grep | grep -v ssh | grep -v stop-server.sh | awk {'print $2'} | head -1) + if [ ! -z $PID ]; then + echo "Stopping ${3} on $1"; + kill -s ${4} ${PID} 2>/dev/null + fi; else - PID=`ssh -q -o 'ConnectTimeout 8' $1 "ps -ef | grep \"$ACCUMULO_HOME\" | egrep '${2}' | grep 'Main ${3}' | grep -v grep | grep -v ssh | grep -v stop-server.sh" | awk {'print $2'} | head -1` - if [ ! -z $PID ]; then - echo "stopping ${3} on $1"; - ssh -q -o 'ConnectTimeout 8' $1 "kill -s ${4} ${PID} 2>/dev/null" - fi; + PID=$(ssh -q -o 'ConnectTimeout 8' $1 "ps -ef | grep \"$ACCUMULO_HOME\" | egrep '${2}' | grep 'Main ${3}' | grep -v grep | grep -v ssh | grep -v stop-server.sh" | awk {'print $2'} | head -1) + if [ ! -z $PID ]; then + echo "Stopping ${3} on $1"; + ssh -q -o 'ConnectTimeout 8' $1 "kill -s ${4} ${PID} 2>/dev/null" + fi; fi Modified: accumulo/trunk/bin/tdown.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/tdown.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/tdown.sh (original) +++ accumulo/trunk/bin/tdown.sh Fri Mar 1 16:54:02 2013 @@ -15,29 +15,35 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh -HADOOP_CMD=$HADOOP_LOCATION/bin/hadoop - +HADOOP_CMD=$HADOOP_PREFIX/bin/hadoop SLAVES=$ACCUMULO_HOME/conf/slaves +SLAVE_HOSTS=$(egrep -v '(^#|^\s*$)' "${SLAVES}") -echo 'stopping unresponsive tablet servers (if any) ...' -for server in `cat $SLAVES | grep -v '^#' `; do - # only start if there's not one already running - $ACCUMULO_HOME/bin/stop-server.sh $server "$ACCUMULO_HOME/.*/accumulo-start.*.jar" tserver TERM & +echo "Stopping unresponsive tablet servers (if any)..." +for server in ${SLAVE_HOSTS}; do + # only start if there's not one already running + $ACCUMULO_HOME/bin/stop-server.sh $server "$ACCUMULO_HOME/.*/accumulo-start.*.jar" tserver TERM & done sleep 10 -echo 'stopping unresponsive tablet servers hard (if any) ...' -for server in `cat $SLAVES | grep -v '^#' `; do - # only start if there's not one already running - $ACCUMULO_HOME/bin/stop-server.sh $server "$ACCUMULO_HOME/.*/accumulo-start.*.jar" tserver KILL & +echo "Stopping unresponsive tablet servers hard (if any)..." +for server in ${SLAVE_HOSTS}; do + # only start if there's not one already running + $ACCUMULO_HOME/bin/stop-server.sh $server "$ACCUMULO_HOME/.*/accumulo-start.*.jar" tserver KILL & done -echo 'Cleaning tablet server entries from zookeeper' +echo "Cleaning tablet server entries from zookeeper" $ACCUMULO_HOME/bin/accumulo org.apache.accumulo.server.util.ZooZap -tservers Modified: accumulo/trunk/bin/tool.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/tool.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/tool.sh (original) +++ accumulo/trunk/bin/tool.sh Fri Mar 1 16:54:02 2013 @@ -15,18 +15,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` . "$bin"/config.sh if [ -z "$HADOOP_PREFIX" ] ; then - echo "HADOOP_PREFIX is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 + echo "HADOOP_PREFIX is not set. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 fi if [ -z "$ZOOKEEPER_HOME" ] ; then - echo "ZOOKEEPER_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" - exit 1 + echo "ZOOKEEPER_HOME is not set. Please make sure it's set globally or in conf/accumulo-env.sh" + exit 1 fi LIB=$ACCUMULO_HOME/lib @@ -39,28 +46,28 @@ TRACE_CMD='ls -1 $LIB/accumulo-trace-*[^ JCOMMANDER_CMD='ls -1 $LIB/jcommander-*[^cs].jar' if [ `eval $ZOOKEEPER_CMD | wc -l` != "1" ] ; then - echo "Not exactly one zookeeper jar in $ZOOKEEPER_HOME" - exit 1 + echo "Not exactly one zookeeper jar in $ZOOKEEPER_HOME" + exit 1 fi if [ `eval $CORE_CMD | wc -l` != "1" ] ; then - echo "Not exactly one accumulo-core jar in $LIB" - exit 1 + echo "Not exactly one accumulo-core jar in $LIB" + exit 1 fi if [ `eval $FATE_CMD | wc -l` != "1" ] ; then - echo "Not exactly one accumulo-fate jar in $LIB" - exit 1 + echo "Not exactly one accumulo-fate jar in $LIB" + exit 1 fi if [ `eval $THRIFT_CMD | wc -l` != "1" ] ; then - echo "Not exactly one thrift jar in $LIB" - exit 1 + echo "Not exactly one thrift jar in $LIB" + exit 1 fi if [ `eval $TRACE_CMD | wc -l` != "1" ] ; then - echo "Not exactly one trace jar in $LIB" - exit 1 + echo "Not exactly one trace jar in $LIB" + exit 1 fi if [ `eval $JCOMMANDER_CMD | wc -l` != "1" ] ; then @@ -68,30 +75,30 @@ if [ `eval $JCOMMANDER_CMD | wc -l` != " exit 1 fi -ZOOKEEPER_LIB=`eval $ZOOKEEPER_CMD` -CORE_LIB=`eval $CORE_CMD` -FATE_LIB=`eval $FATE_CMD` -THRIFT_LIB=`eval $THRIFT_CMD` -TRACE_LIB=`eval $TRACE_CMD` -JCOMMANDER_LIB=`eval $JCOMMANDER_CMD` +ZOOKEEPER_LIB=$(eval $ZOOKEEPER_CMD) +CORE_LIB=$(eval $CORE_CMD) +FATE_LIB=$(eval $FATE_CMD) +THRIFT_LIB=$(eval $THRIFT_CMD) +TRACE_LIB=$(eval $TRACE_CMD) +JCOMMANDER_LIB=$(eval $JCOMMANDER_CMD) USERJARS=" " for arg in "$@"; do - if [ "$arg" != "-libjars" -a -z "$TOOLJAR" ]; then - TOOLJAR="$arg" - shift - elif [ "$arg" != "-libjars" -a -z "$CLASSNAME" ]; then - CLASSNAME="$arg" - shift - elif [ -z "$USERJARS" ]; then - USERJARS=`echo "$arg" | tr "," " "` - shift - elif [ "$arg" = "-libjars" ]; then - USERJARS="" - shift - else - break - fi + if [ "$arg" != "-libjars" -a -z "$TOOLJAR" ]; then + TOOLJAR="$arg" + shift + elif [ "$arg" != "-libjars" -a -z "$CLASSNAME" ]; then + CLASSNAME="$arg" + shift + elif [ -z "$USERJARS" ]; then + USERJARS=$(echo "$arg" | tr "," " ") + shift + elif [ "$arg" = "-libjars" ]; then + USERJARS="" + shift + else + break + fi done LIB_JARS="$THRIFT_LIB,$CORE_LIB,$FATE_LIB,$ZOOKEEPER_LIB,$TRACE_LIB,$JCOMMANDER_LIB" @@ -99,14 +106,14 @@ H_JARS="$THRIFT_LIB:$CORE_LIB:$FATE_LIB: COMMONS_LIBS=`ls -1 $LIB/commons-*.jar` for jar in $USERJARS $COMMONS_LIBS; do - LIB_JARS="$LIB_JARS,$jar" - H_JARS="$H_JARS$jar:" + LIB_JARS="$LIB_JARS,$jar" + H_JARS="$H_JARS$jar:" done export HADOOP_CLASSPATH=$H_JARS$HADOOP_CLASSPATH if [ -z "$CLASSNAME" -o -z "$TOOLJAR" ]; then - echo "Usage: tool.sh path/to/myTool.jar my.tool.class.Name [-libjars my1.jar,my2.jar]" 1>&2 - exit 1 + echo "Usage: tool.sh path/to/myTool.jar my.tool.class.Name [-libjars my1.jar,my2.jar]" 1>&2 + exit 1 fi #echo USERJARS=$USERJARS Modified: accumulo/trunk/bin/tup.sh URL: http://svn.apache.org/viewvc/accumulo/trunk/bin/tup.sh?rev=1451647&r1=1451646&r2=1451647&view=diff ============================================================================== --- accumulo/trunk/bin/tup.sh (original) +++ accumulo/trunk/bin/tup.sh Fri Mar 1 16:54:02 2013 @@ -15,9 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. - -bin=`dirname "$0"` -bin=`cd "$bin"; pwd` +# Start: Resolve Script Directory +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$bin/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Stop: Resolve Script Directory . "$bin"/config.sh @@ -26,17 +32,15 @@ SLAVES=$ACCUMULO_HOME/conf/slaves echo -n "Starting tablet servers ..." count=1 -for server in `grep -v '^#' "$SLAVES"` -do - echo -n "." - ${bin}/start-server.sh $server tserver "tablet server" & - count=`expr $count + 1` - if [ `expr $count % 72` -eq 0 ] ; - then - echo - wait - fi +for server in `egrep -v '(^#|^\s*$)' "${SLAVES}"`; do + echo -n "." + ${bin}/start-server.sh $server tserver "tablet server" & + let count++ + if [ $(( ${count} % 72 )) -eq 0 ] ; + then + echo + wait + fi done echo " done" - Propchange: accumulo/trunk/core/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/core:r1451640 Propchange: accumulo/trunk/examples/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/examples:r1451640 Propchange: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java:r1451640 Propchange: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java:r1451640 Propchange: accumulo/trunk/server/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/server:r1451640 Propchange: accumulo/trunk/src/ ------------------------------------------------------------------------------ Merged /accumulo/branches/1.5/src:r1451640