ACCUMULO-4490 Fix shellcheck issues
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2e3b62a8 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2e3b62a8 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2e3b62a8 Branch: refs/heads/master Commit: 2e3b62a846689657b709dfa5dd910c593dab6a16 Parents: 158cf16 Author: Christopher Tubbs <ctubb...@apache.org> Authored: Mon Oct 31 15:34:18 2016 -0400 Committer: Mike Walch <mwa...@apache.org> Committed: Tue Nov 8 15:37:05 2016 -0500 ---------------------------------------------------------------------- assemble/bin/accumulo | 8 +- assemble/libexec/accumulo-watcher.sh | 74 +++++++------- assemble/libexec/bootstrap-hdfs.sh | 36 +++---- assemble/libexec/cluster.sh | 130 +++++++++++------------ assemble/libexec/config.sh | 100 +++++++++--------- assemble/libexec/service.sh | 164 +++++++++++++++--------------- assemble/libexec/tool.sh | 10 +- 7 files changed, 262 insertions(+), 260 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/bin/accumulo ---------------------------------------------------------------------- diff --git a/assemble/bin/accumulo b/assemble/bin/accumulo index 1d0e704..21ce5a1 100755 --- a/assemble/bin/accumulo +++ b/assemble/bin/accumulo @@ -43,7 +43,7 @@ function build_native() { cd "${native_dir}" || exit 1 # Make the native library - export USERFLAGS="$@" + export USERFLAGS="$*" if ! make then echo "Make failed!" @@ -76,7 +76,7 @@ function main() { "$basedir/libexec/config.sh" "${@:2}" exit 0 elif [[ "$1" == "build-native" ]]; then - build_native ${*:2} + build_native "${@:2}" exit 0 fi @@ -139,7 +139,7 @@ function main() { exit 1 fi - if [[ ! " gc master monitor tserver tracer " =~ " $1 " ]]; then + if [[ ! "$1" =~ ^(gc|master|monitor|tserver|traser)$ ]]; then if [[ -f ${ACCUMULO_CONF_DIR}/log4j.properties ]]; then export ACCUMULO_OPTS="${ACCUMULO_OPTS} -Dlog4j.configuration=file:${ACCUMULO_CONF_DIR}/log4j.properties" else @@ -184,6 +184,8 @@ function main() { # app isn't used anywhere, but it makes the process easier to spot when ps/top/snmp truncate the command line JAVA="${JAVA_HOME}/bin/java" + + ACCUMULO_OPTS_ARRAY=(${ACCUMULO_OPTS}) exec "$JAVA" "-Dapp=$1" \ $INSTANCE_OPT \ "${ACCUMULO_OPTS_ARRAY[@]}" \ http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/accumulo-watcher.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/accumulo-watcher.sh b/assemble/libexec/accumulo-watcher.sh index bebe42e..1731cdd 100755 --- a/assemble/libexec/accumulo-watcher.sh +++ b/assemble/libexec/accumulo-watcher.sh @@ -53,7 +53,7 @@ logger -s "starting process $process at $(date)" stopRunning="" while [ -z "$stopRunning" ]; do - eval $COMMAND 2> $ERRFILE + eval "$COMMAND" 2> "$ERRFILE" exit=$? unset cause if [ "$exit" -eq 0 ]; then @@ -73,26 +73,26 @@ do if [ $exit -eq 1 ]; then source="exit code" cause=$UNEXPECTED_EXCEPTION - elif tail -n50 $OUTFILE | grep "java.lang.OutOfMemoryError:" > /dev/null; then + elif tail -n50 "$OUTFILE" | grep "java.lang.OutOfMemoryError:" > /dev/null; then source="logs" cause=$OOM_EXCEPTION elif [ "$process" = "tserver" ]; then - if tail -n50 $DEBUGLOG | grep "ERROR: Lost tablet server lock (reason =" > /dev/null ; then + if tail -n50 "$DEBUGLOG" | grep "ERROR: Lost tablet server lock (reason =" > /dev/null ; then source="logs" cause=$ZKLOCK_LOST fi elif [ "$process" = "master" ]; then - if tail -n50 $DEBUGLOG | grep "ERROR: Master lock in zookeeper lost (reason =" > /dev/null ; then + if tail -n50 "$DEBUGLOG" | grep "ERROR: Master lock in zookeeper lost (reason =" > /dev/null ; then source="logs" cause=$ZKLOCK_LOST fi elif [ "$process" = "gc" ]; then - if tail -n50 $DEBUGLOG | grep "FATAL: GC lock in zookeeper lost (reason =" > /dev/null ; then + if tail -n50 "$DEBUGLOG" | grep "FATAL: GC lock in zookeeper lost (reason =" > /dev/null ; then source="logs" cause=$ZKLOCK_LOST fi elif [ "$process" = "monitor" ]; then - if tail -n50 $DEBUGLOG | grep "ERROR: Monitor lock in zookeeper lost (reason =" > /dev/null ; then + if tail -n50 "$DEBUGLOG" | grep "ERROR: Monitor lock in zookeeper lost (reason =" > /dev/null ; then source="logs" cause=$ZKLOCK_LOST fi @@ -103,39 +103,39 @@ do case $cause in #Unknown exit code "$UNKNOWN_ERROR") - #window doesn't matter when retries = 0 - RETRIES=0 - ;; + #window doesn't matter when retries = 0 + RETRIES=0 + ;; - "$UNEXPECTED_EXCEPTION") - WINDOW=$UNEXPECTED_TIMESPAN - RETRIES=$UNEXPECTED_RETRIES - ;; + "$UNEXPECTED_EXCEPTION") + WINDOW=$UNEXPECTED_TIMESPAN + RETRIES=$UNEXPECTED_RETRIES + ;; - "$OOM_EXCEPTION") - WINDOW=$OOM_TIMESPAN - RETRIES=$OOM_RETRIES - ;; + "$OOM_EXCEPTION") + WINDOW=$OOM_TIMESPAN + RETRIES=$OOM_RETRIES + ;; - "$ZLOCK_LOST") - WINDOW=$ZKLOCK_TIMESPAN - RETRIES=$ZKLOCK_RETRIES - ;; - esac + "$ZKLOCK_LOST") + WINDOW=$ZKLOCK_TIMESPAN + RETRIES=$ZKLOCK_RETRIES + ;; + esac - if [ -n "$cause" ]; then - stopRunning="" - declare -i attempts - attempts="`jobs | grep "reason$cause" | wc -l`+1" - if [ "$RETRIES" -le $attempts ]; then - stopRunning="$process encountered $cause in $source with exit code $exit- quitting ($attempts/$RETRIES in $WINDOW seconds)" - # kill all sleeps now - for list in `jobs | cut -b 2-2`; do kill %$list; done - else - logger -s "$process encountered $cause in $source with exit code $exit- retrying ($attempts/$RETRIES in $WINDOW seconds)" - eval "(sleep $WINDOW ; echo "reason$cause" >> /dev/null) &" - fi - fi - fi + if [ -n "$cause" ]; then + stopRunning="" + declare -i attempts + attempts="$(jobs | grep -c "reason$cause")+1" + if [ "$RETRIES" -le "$attempts" ]; then + stopRunning="$process encountered $cause in $source with exit code $exit- quitting ($attempts/$RETRIES in $WINDOW seconds)" + # kill all sleeps now + for list in $(jobs | cut -b 2-2); do kill %"$list"; done + else + logger -s "$process encountered $cause in $source with exit code $exit- retrying ($attempts/$RETRIES in $WINDOW seconds)" + eval "(sleep $WINDOW ; echo 'reason$cause' >> /dev/null) &" + fi + fi +fi done -logger -s $stopRunning +logger -s "$stopRunning" http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/bootstrap-hdfs.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/bootstrap-hdfs.sh b/assemble/libexec/bootstrap-hdfs.sh index b678f27..7748604 100755 --- a/assemble/libexec/bootstrap-hdfs.sh +++ b/assemble/libexec/bootstrap-hdfs.sh @@ -34,17 +34,17 @@ SYSTEM_CONTEXT_HDFS_DIR=$(grep -A1 "general.vfs.classpaths" "$ACCUMULO_CONF_DIR/ 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 where ##CLASSPATH## is one of the following formats:" - echo "A single directory: hdfs://host:port/directory/" - echo "A single directory with a regex: hdfs://host:port/directory/.*.jar" - echo "Multiple directories: hdfs://host:port/directory/.*.jar,hdfs://host:port/directory2/" - echo "" - echo "<property>" - echo " <name>general.vfs.classpaths</name>" - echo " <value>##CLASSPATH##</value>" - echo " <description>location of the jars for the default (system) context</description>" - echo "</property>" - exit 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 where ##CLASSPATH## is one of the following formats:" + echo "A single directory: hdfs://host:port/directory/" + echo "A single directory with a regex: hdfs://host:port/directory/.*.jar" + echo "Multiple directories: hdfs://host:port/directory/.*.jar,hdfs://host:port/directory2/" + echo "" + echo "<property>" + echo " <name>general.vfs.classpaths</name>" + echo " <value>##CLASSPATH##</value>" + echo " <description>location of the jars for the default (system) context</description>" + echo "</property>" + exit 1 fi # @@ -52,11 +52,11 @@ fi # "$HADOOP_PREFIX/bin/hadoop" fs -ls "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null if [[ $? != 0 ]]; then - "$HADOOP_PREFIX/bin/hadoop" fs -mkdir "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null - if [[ $? != 0 ]]; then - echo "Unable to create classpath directory at $SYSTEM_CONTEXT_HDFS_DIR" - exit 1 - fi + "$HADOOP_PREFIX/bin/hadoop" fs -mkdir "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null + if [[ $? != 0 ]]; then + echo "Unable to create classpath directory at $SYSTEM_CONTEXT_HDFS_DIR" + exit 1 + fi fi # @@ -72,7 +72,7 @@ REP=$(( NUM_TSERVERS / 50 )) # # Copy all jars in lib to the system context directory # -"$HADOOP_PREFIX/bin/hadoop" fs -moveFromLocal "$ACCUMULO_LIB_DIR/*.jar "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null +"$HADOOP_PREFIX/bin/hadoop" fs -moveFromLocal "$ACCUMULO_LIB_DIR"/*.jar "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null "$HADOOP_PREFIX/bin/hadoop" fs -setrep -R $REP "$SYSTEM_CONTEXT_HDFS_DIR" > /dev/null # @@ -86,5 +86,5 @@ REP=$(( NUM_TSERVERS / 50 )) "$HADOOP_PREFIX/bin/hadoop" fs -rm "$SYSTEM_CONTEXT_HDFS_DIR/slf4j*.jar" > /dev/null for f in $(grep -v '^#' "$ACCUMULO_CONF_DIR/tservers") do - rsync -ra --delete "$ACCUMULO_HOME" $(dirname "$ACCUMULO_HOME") + rsync -ra --delete "$ACCUMULO_HOME" "$(dirname "$ACCUMULO_HOME")" done http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/cluster.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/cluster.sh b/assemble/libexec/cluster.sh index d3a2f5a..4f74138 100755 --- a/assemble/libexec/cluster.sh +++ b/assemble/libexec/cluster.sh @@ -44,7 +44,7 @@ function get_ip() { ip_addr=$($net_cmd 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_addr=$(python -c 'import socket as s; print s.gethostbyname(s.getfqdn())') + ip_addr=$(python -c 'import socket as s; print s.gethostbyname(s.getfqdn())') fi echo "$ip_addr" } @@ -64,13 +64,13 @@ function start_tservers() { echo -n "Starting tablet servers ..." count=1 for server in $(egrep -v '(^#|^\s*$)' "${ACCUMULO_CONF_DIR}/tservers"); do - echo -n "." - start_service "$server" tserver & - if (( ++count % 72 == 0 )) ; - then - echo - wait - fi + echo -n "." + start_service "$server" tserver & + if (( ++count % 72 == 0 )) ; + then + echo + wait + fi done echo " done" } @@ -81,20 +81,20 @@ function start_all() { start_service "$monitor" monitor if [ "$1" != "--notTservers" ]; then - start_tservers + start_tservers fi ${accumulo_cmd} org.apache.accumulo.master.state.SetGoalState NORMAL for master in $(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/masters"); do - start_service "$master" master + start_service "$master" master done for gc in $(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/gc"); do - start_service "$gc" gc + start_service "$gc" gc done for tracer in $(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/tracers"); do - start_service "$tracer" tracer + start_service "$tracer" tracer done } @@ -102,39 +102,39 @@ function start_here() { local_hosts="$(hostname -a 2> /dev/null) $(hostname) localhost 127.0.0.1 $(get_ip)" for host in $local_hosts; do - if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/tservers"; then - start_service "$host" tserver - break - fi + if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/tservers"; then + start_service "$host" tserver + break + fi done for host in $local_hosts; do - if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/masters"; then - ${accumulo_cmd} org.apache.accumulo.master.state.SetGoalState NORMAL - start_service "$host" master - break - fi + if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/masters"; then + ${accumulo_cmd} org.apache.accumulo.master.state.SetGoalState NORMAL + start_service "$host" master + break + fi done for host in $local_hosts; do - if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/gc"; then - start_service "$host" gc - break - fi + if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/gc"; then + start_service "$host" gc + break + fi done for host in $local_hosts; do - if [[ $host == "$monitor" ]]; then - start_service "$monitor" monitor - break - fi + if [[ $host == "$monitor" ]]; then + start_service "$monitor" monitor + break + fi done for host in $local_hosts; do - if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/tracers"; then - start_service "$host" tracer - break - fi + if grep -q "^${host}\$" "$ACCUMULO_CONF_DIR/tracers"; then + start_service "$host" tracer + break + fi done } @@ -156,16 +156,16 @@ function stop_tservers() { echo "Stopping unresponsive tablet servers (if any)..." for server in ${tserver_hosts}; do - # only start if there's not one already running - stop_service "$server" tserver TERM & + # only start if there's not one already running + stop_service "$server" tserver TERM & done sleep 10 echo "Stopping unresponsive tablet servers hard (if any)..." for server in ${tserver_hosts}; do - # only start if there's not one already running - stop_service "$server" tserver KILL & + # only start if there's not one already running + stop_service "$server" tserver KILL & done echo "Cleaning tablet server entries from zookeeper" @@ -176,32 +176,32 @@ function stop_all() { echo "Stopping accumulo services..." if ! ${accumulo_cmd} admin stopAll then - echo "Invalid password or unable to connect to the master" - echo "Initiating forced shutdown in 15 seconds (Ctrl-C to abort)" - sleep 10 - echo "Initiating forced shutdown in 5 seconds (Ctrl-C to abort)" + echo "Invalid password or unable to connect to the master" + echo "Initiating forced shutdown in 15 seconds (Ctrl-C to abort)" + sleep 10 + echo "Initiating forced shutdown in 5 seconds (Ctrl-C to abort)" else - echo "Accumulo shut down cleanly" - echo "Utilities and unresponsive servers will shut down in 5 seconds (Ctrl-C to abort)" + echo "Accumulo shut down cleanly" + echo "Utilities and unresponsive servers will shut down in 5 seconds (Ctrl-C to abort)" fi 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_CONF_DIR/masters"); do - stop_service "$master" master $signal - done + for master in $(grep -v '^#' "$ACCUMULO_CONF_DIR/masters"); do + stop_service "$master" master $signal + done - for gc in $(grep -v '^#' "$ACCUMULO_CONF_DIR/gc"); do - stop_service "$gc" gc $signal - done + for gc in $(grep -v '^#' "$ACCUMULO_CONF_DIR/gc"); do + stop_service "$gc" gc $signal + done - stop_service "$monitor" monitor $signal + stop_service "$monitor" monitor $signal - for tracer in $(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/tracers"); do - stop_service "$tracer" tracer $signal - done + for tracer in $(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/tracers"); do + stop_service "$tracer" tracer $signal + done done # stop tserver still running @@ -216,21 +216,21 @@ function stop_here() { hosts_to_check=($(hostname -a 2> /dev/null | head -1) $(hostname -f)) if egrep -q localhost\|127.0.0.1 "$ACCUMULO_CONF_DIR/tservers"; then - ${accumulo_cmd} admin stop localhost + ${accumulo_cmd} admin stop localhost else - for host in "${hosts_to_check[@]}"; do - if grep -q "$host" "$ACCUMULO_CONF_DIR"/tservers; then - ${accumulo_cmd} admin stop "$host" - fi - done + for host in "${hosts_to_check[@]}"; do + if grep -q "$host" "$ACCUMULO_CONF_DIR"/tservers; then + ${accumulo_cmd} admin stop "$host" + fi + done fi for host in "${hosts_to_check[@]}"; do - for signal in TERM KILL; do - for svc in tserver gc master monitor tracer; do - stop_service "$host" $svc $signal - done - done + for signal in TERM KILL; do + for svc in tserver gc master monitor tracer; do + stop_service "$host" $svc $signal + done + done done } @@ -268,7 +268,7 @@ function main() { if [[ -z "${monitor}" ]] ; then monitor=$master1 if [[ -f "$ACCUMULO_CONF_DIR/monitor" ]]; then - monitor=$(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/monitor" | head -1) + monitor=$(egrep -v '(^#|^\s*$)' "$ACCUMULO_CONF_DIR/monitor" | head -1) fi if [[ -z "${monitor}" ]] ; then echo "Could not infer a Monitor role. You need to either define \"${ACCUMULO_CONF_DIR}/monitor\"," http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/config.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/config.sh b/assemble/libexec/config.sh index 6a7ffaf..87f51e0 100755 --- a/assemble/libexec/config.sh +++ b/assemble/libexec/config.sh @@ -57,7 +57,7 @@ KERBEROS= if [[ $(uname -s) == "Linux" ]]; then args=$(getopt -o "b:d:s:njokv:h" -l "basedir:,dir:,size:,native,jvm,overwrite,kerberos,version:,help" -q -- "$@") else # Darwin, BSD - args=$(getopt b:d:s:njokv:h $*) + args=$(getopt b:d:s:njokv:h "$@") fi #Bad arguments @@ -65,7 +65,7 @@ if [[ $? != 0 ]]; then usage 1>&2 exit 1 fi -eval set -- $args +eval set -- "${args[@]}" for i do @@ -99,8 +99,8 @@ do exit 0 shift;; --) - shift - break;; + shift + break;; esac done @@ -293,97 +293,97 @@ if [[ ! -z "${BASE_DIR}" ]]; then MAVEN_PROJ_BASEDIR="\n <property>\n <name>general.maven.project.basedir</name>\n <value>${BASE_DIR}</value>\n </property>\n" fi -mkdir -p "${CONF_DIR}" && cp ${TEMPLATE_CONF_DIR}/* ${CONF_DIR}/ +mkdir -p "${CONF_DIR}" && cp "${TEMPLATE_CONF_DIR}"/* "${CONF_DIR}"/ if [[ -f "${CONF_DIR}/examples/client.conf" ]]; then - cp ${CONF_DIR}/examples/client.conf ${CONF_DIR}/ + cp "${CONF_DIR}"/examples/client.conf "${CONF_DIR}"/ fi #Configure accumulo-env.sh sed -e "s/\${tServerHigh_tServerLow}/${!TSERVER}/" \ - -e "s/\${masterHigh_masterLow}/${!MASTER}/" \ - -e "s/\${monitorHigh_monitorLow}/${!MONITOR}/" \ - -e "s/\${gcHigh_gcLow}/${!GC}/" \ - -e "s/\${shellHigh_shellLow}/${!SHELL}/" \ - -e "s/\${otherHigh_otherLow}/${!OTHER}/" \ - ${TEMPLATE_CONF_DIR}/$ACCUMULO_ENV > ${CONF_DIR}/$ACCUMULO_ENV + -e "s/\${masterHigh_masterLow}/${!MASTER}/" \ + -e "s/\${monitorHigh_monitorLow}/${!MONITOR}/" \ + -e "s/\${gcHigh_gcLow}/${!GC}/" \ + -e "s/\${shellHigh_shellLow}/${!SHELL}/" \ + -e "s/\${otherHigh_otherLow}/${!OTHER}/" \ + "${TEMPLATE_CONF_DIR}/$ACCUMULO_ENV" > "${CONF_DIR}/$ACCUMULO_ENV" #Configure accumulo-site.xml sed -e "s/\${memMapMax}/${!MEMORY_MAP_MAX}/" \ - -e "s/\${nativeEnabled}/${!NATIVE}/" \ - -e "s/\${cacheDataSize}/${!CACHE_DATA_SIZE}/" \ - -e "s/\${cacheIndexSize}/${!CACHE_INDEX_SIZE}/" \ - -e "s/\${sortBufferSize}/${!SORT_BUFFER_SIZE}/" \ - -e "s/\${waLogMaxSize}/${!WAL_MAX_SIZE}/" \ - -e "s=\${traceUser}=${TRACE_USER}=" \ - -e "s=\${mvnProjBaseDir}=${MAVEN_PROJ_BASEDIR}=" ${TEMPLATE_CONF_DIR}/$ACCUMULO_SITE > ${CONF_DIR}/$ACCUMULO_SITE + -e "s/\${nativeEnabled}/${!NATIVE}/" \ + -e "s/\${cacheDataSize}/${!CACHE_DATA_SIZE}/" \ + -e "s/\${cacheIndexSize}/${!CACHE_INDEX_SIZE}/" \ + -e "s/\${sortBufferSize}/${!SORT_BUFFER_SIZE}/" \ + -e "s/\${waLogMaxSize}/${!WAL_MAX_SIZE}/" \ + -e "s=\${traceUser}=${TRACE_USER}=" \ + -e "s=\${mvnProjBaseDir}=${MAVEN_PROJ_BASEDIR}=" "${TEMPLATE_CONF_DIR}/$ACCUMULO_SITE" > "${CONF_DIR}/$ACCUMULO_SITE" # If we're not using kerberos, filter out the krb properties if [[ -z "${KERBEROS}" ]]; then sed -e 's/<!-- Kerberos requirements -->/<!-- Kerberos requirements --><!--/' \ - -e 's/<!-- End Kerberos requirements -->/--><!-- End Kerberos requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End Kerberos requirements -->/--><!-- End Kerberos requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" else # Make the substitutions sed -e "s!\${keytab}!${KEYTAB}!" \ - -e "s!\${principal}!${PRINCIPAL}!" \ - ${CONF_DIR}/${ACCUMULO_SITE} > temp - mv temp ${CONF_DIR}/${ACCUMULO_SITE} + -e "s!\${principal}!${PRINCIPAL}!" \ + "${CONF_DIR}/${ACCUMULO_SITE}" > temp + mv temp "${CONF_DIR}/${ACCUMULO_SITE}" fi # Configure hadoop version if [[ "${HADOOP_VERSION}" == "2" ]]; then sed -e 's/<!-- HDP 2.0 requirements -->/<!-- HDP 2.0 requirements --><!--/' \ - -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- HDP 2.2 requirements -->/<!-- HDP 2.2 requirements --><!--/' \ - -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- IOP 4.1 requirements -->/<!-- IOP 4.1 requirements --><!--/' \ - -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" elif [[ "${HADOOP_VERSION}" == "HDP2" ]]; then sed -e 's/<!-- Hadoop 2 requirements -->/<!-- Hadoop 2 requirements --><!--/' \ - -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- HDP 2.2 requirements -->/<!-- HDP 2.2 requirements --><!--/' \ - -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- IOP 4.1 requirements -->/<!-- IOP 4.1 requirements --><!--/' \ - -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" elif [[ "${HADOOP_VERSION}" == "HDP2.2" ]]; then sed -e 's/<!-- Hadoop 2 requirements -->/<!-- Hadoop 2 requirements --><!--/' \ - -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- HDP 2.0 requirements -->/<!-- HDP 2.0 requirements --><!--/' \ - -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- IOP 4.1 requirements -->/<!-- IOP 4.1 requirements --><!--/' \ - -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End IOP 4.1 requirements -->/--><!-- End IOP 4.1 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" elif [[ "${HADOOP_VERSION}" == "IOP4.1" ]]; then sed -e 's/<!-- Hadoop 2 requirements -->/<!-- Hadoop 2 requirements --><!--/' \ - -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End Hadoop 2 requirements -->/--><!-- End Hadoop 2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- HDP 2.0 requirements -->/<!-- HDP 2.0 requirements --><!--/' \ - -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.0 requirements -->/--><!-- End HDP 2.0 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" sed -e 's/<!-- HDP 2.2 requirements -->/<!-- HDP 2.2 requirements --><!--/' \ - -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ - "${CONF_DIR}/$ACCUMULO_SITE" > temp + -e 's/<!-- End HDP 2.2 requirements -->/--><!-- End HDP 2.2 requirements -->/' \ + "${CONF_DIR}/$ACCUMULO_SITE" > temp mv temp "${CONF_DIR}/$ACCUMULO_SITE" fi @@ -393,11 +393,11 @@ if [[ ${TYPE} == native ]]; then if [[ -z $HADOOP_PREFIX ]]; then echo "WARNING: HADOOP_PREFIX not set, cannot automatically configure LD_LIBRARY_PATH to include Hadoop native libraries" else - NATIVE_LIB=$(readlink -ef $(dirname $(for x in $(find $HADOOP_PREFIX -name libhadoop.so); do ld $x 2>/dev/null && echo $x && break; done) 2>>/dev/null) 2>>/dev/null) + NATIVE_LIB=$(readlink -ef "$(dirname "$(for x in $(find "$HADOOP_PREFIX" -name libhadoop.so); do ld "$x" 2>/dev/null && echo "$x" && break; done)" 2>>/dev/null)" 2>>/dev/null) if [[ -z $NATIVE_LIB ]]; then echo -e "WARNING: The Hadoop native libraries could not be found for your sytem in: $HADOOP_PREFIX" else - sed "/# Should the monitor/ i export LD_LIBRARY_PATH=${NATIVE_LIB}:\${LD_LIBRARY_PATH}" ${CONF_DIR}/$ACCUMULO_ENV > temp + sed "/# Should the monitor/ i export LD_LIBRARY_PATH=${NATIVE_LIB}:\${LD_LIBRARY_PATH}" "${CONF_DIR}/$ACCUMULO_ENV" > temp mv temp "${CONF_DIR}/$ACCUMULO_ENV" echo -e "Added ${NATIVE_LIB} to the LD_LIBRARY_PATH" fi http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/service.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/service.sh b/assemble/libexec/service.sh index b34d9ba..f422d15 100755 --- a/assemble/libexec/service.sh +++ b/assemble/libexec/service.sh @@ -36,14 +36,14 @@ function invalid_args { rotate_log () { logfile=$1; max_retained=$2; - if [[ ! $max_retained =~ ^[0-9]+$ ]] || [[ $max_retained -lt 1 ]] ; then + if [[ ! "$max_retained" =~ ^[0-9]+$ ]] || [[ "$max_retained" -lt 1 ]] ; then echo "ACCUMULO_NUM_OUT_FILES should be a positive number, but was '$max_retained'" exit 1 fi if [ -f "$logfile" ]; then # rotate logs - while [ $max_retained -gt 1 ]; do - prev=`expr $max_retained - 1` + while [[ "$max_retained" -gt 1 ]]; do + prev=$(( max_retained - 1)) [ -f "$logfile.$prev" ] && mv -f "$logfile.$prev" "$logfile.$max_retained" max_retained=$prev done @@ -66,12 +66,12 @@ function start_service() { # When the hostname provided is the alias/shortname, try to use the FQDN to make # sure we send the right address to the Accumulo process. if [[ "$host" = "$(hostname -s)" ]]; then - host="$(hostname -f)" - address="$host" + host="$(hostname -f)" + address="$host" fi if [[ ${service} == "monitor" && ${ACCUMULO_MONITOR_BIND_ALL} == "true" ]]; then - address="0.0.0.0" + address="0.0.0.0" fi COMMAND="${ACCUMULO_BIN_DIR}/accumulo" @@ -83,102 +83,102 @@ function start_service() { ERRFILE="${ACCUMULO_LOG_DIR}/${service}_${loghost}.err" # Rotate the .out and .err files - rotate_log "$OUTFILE" ${ACCUMULO_NUM_OUT_FILES} - rotate_log "$ERRFILE" ${ACCUMULO_NUM_OUT_FILES} + rotate_log "$OUTFILE" "${ACCUMULO_NUM_OUT_FILES}" + rotate_log "$ERRFILE" "${ACCUMULO_NUM_OUT_FILES}" # NUMA sanity check if [[ $ACCUMULO_NUM_TSERVERS -eq 1 && -n $TSERVER_NUMA_OPTIONS ]]; then - echo "TSERVER_NUMA_OPTIONS declared when ACCUMULO_NUM_TSERVERS is 1, use ACCUMULO_NUMACTL_OPTIONS instead" - exit 1 + echo "TSERVER_NUMA_OPTIONS declared when ACCUMULO_NUM_TSERVERS is 1, use ACCUMULO_NUMACTL_OPTIONS instead" + exit 1 fi if [[ $ACCUMULO_NUM_TSERVERS -gt 1 && -n $TSERVER_NUMA_OPTIONS && ${#TSERVER_NUMA_OPTIONS[*]} -ne $ACCUMULO_NUM_TSERVERS ]]; then - echo "TSERVER_NUMA_OPTIONS is declared, but not the same size as ACCUMULO_NUM_TSERVERS" - exit 1 + echo "TSERVER_NUMA_OPTIONS is declared, but not the same size as ACCUMULO_NUM_TSERVERS" + exit 1 fi if [[ "$service" != "tserver" || $ACCUMULO_NUM_TSERVERS -eq 1 ]]; then - # Check the pid file to figure out if its already running. - PID_FILE="${ACCUMULO_PID_DIR}/accumulo-${ACCUMULO_IDENT_STRING}-${service}.pid" - if [ -f ${PID_FILE} ]; then - PID=`cat ${PID_FILE}` - if kill -0 $PID 2>/dev/null; then - # Starting an already-started service shouldn't be an error per LSB - echo "$host : $service already running (${PID})" - exit 0 - fi - fi - echo "Starting $service on $host" - - ACCUMULO_ENABLE_NUMACTL=${ACCUMULO_ENABLE_NUMACTL:-"true"} - ACCUMULO_NUMACTL_OPTIONS=${ACCUMULO_NUMACTL_OPTIONS:-"--interleave=all"} - NUMA=`which numactl 2>/dev/null` - NUMACTL_EXISTS="$?" - if [[ ( ${NUMACTL_EXISTS} -eq 0 ) && ( ${ACCUMULO_ENABLE_NUMACTL} == "true" ) ]] ; then - export NUMA_CMD="${NUMA} ${ACCUMULO_NUMACTL_OPTIONS}" - else - export NUMA_CMD="" - fi - - # Fork the process, store the pid - nohup ${NUMA_CMD} "$COMMAND" "${service}" --address "${address}" >"$OUTFILE" 2>"$ERRFILE" < /dev/null & - echo $! > ${PID_FILE} + # Check the pid file to figure out if its already running. + PID_FILE="${ACCUMULO_PID_DIR}/accumulo-${ACCUMULO_IDENT_STRING}-${service}.pid" + if [[ -f "${PID_FILE}" ]]; then + PID=$(cat "${PID_FILE}") + if kill -0 "$PID" 2>/dev/null; then + # Starting an already-started service shouldn't be an error per LSB + echo "$host : $service already running (${PID})" + exit 0 + fi + fi + echo "Starting $service on $host" + + ACCUMULO_ENABLE_NUMACTL=${ACCUMULO_ENABLE_NUMACTL:-"true"} + ACCUMULO_NUMACTL_OPTIONS=${ACCUMULO_NUMACTL_OPTIONS:-"--interleave=all"} + NUMA=$(which numactl 2>/dev/null) + NUMACTL_EXISTS="$?" + if [[ ( ${NUMACTL_EXISTS} -eq 0 ) && ( ${ACCUMULO_ENABLE_NUMACTL} == "true" ) ]] ; then + export NUMA_CMD="${NUMA} ${ACCUMULO_NUMACTL_OPTIONS}" + else + export NUMA_CMD="" + fi + + # Fork the process, store the pid + nohup ${NUMA_CMD} "$COMMAND" "${service}" --address "${address}" >"$OUTFILE" 2>"$ERRFILE" < /dev/null & + echo $! > "${PID_FILE}" else - S="$service" - for (( t=1; t<=$ACCUMULO_NUM_TSERVERS; t++)); do + S="$service" + for (( t=1; t<=ACCUMULO_NUM_TSERVERS; t++)); do - service="$S-$t" + service="$S-$t" - # Check the pid file to figure out if its already running. - PID_FILE="${ACCUMULO_PID_DIR}/accumulo-${ACCUMULO_IDENT_STRING}-${service}.pid" - if [ -f ${PID_FILE} ]; then - PID=`cat ${PID_FILE}` - if kill -0 $PID 2>/dev/null; then - # Starting an already-started service shouldn't be an error per LSB - echo "$host : $service already running (${PID})" - continue - fi + # Check the pid file to figure out if its already running. + PID_FILE="${ACCUMULO_PID_DIR}/accumulo-${ACCUMULO_IDENT_STRING}-${service}.pid" + if [[ -f "${PID_FILE}" ]]; then + PID=$(cat "${PID_FILE}") + if kill -0 "$PID" 2>/dev/null; then + # Starting an already-started service shouldn't be an error per LSB + echo "$host : $service already running (${PID})" + continue fi - echo "Starting $service on $host" - - ACCUMULO_NUMACTL_OPTIONS=${ACCUMULO_NUMACTL_OPTIONS:-"--interleave=all"} - ACCUMULO_NUMACTL_OPTIONS=${TSERVER_NUMA_OPTIONS[$t]} - if [[ "$ACCUMULO_ENABLE_NUMACTL" == "true" ]]; then - NUMA=`which numactl 2>/dev/null` - NUMACTL_EXISTS=$? - if [[ ( ${NUMACTL_EXISTS} -eq 0 ) ]]; then - export NUMA_CMD="${NUMA} ${ACCUMULO_NUMACTL_OPTIONS}" - else - export NUMA_CMD="" - fi + fi + echo "Starting $service on $host" + + ACCUMULO_NUMACTL_OPTIONS=${ACCUMULO_NUMACTL_OPTIONS:-"--interleave=all"} + ACCUMULO_NUMACTL_OPTIONS=${TSERVER_NUMA_OPTIONS[$t]} + if [[ "$ACCUMULO_ENABLE_NUMACTL" == "true" ]]; then + NUMA=$(which numactl 2>/dev/null) + NUMACTL_EXISTS=$? + if [[ ( ${NUMACTL_EXISTS} -eq 0 ) ]]; then + export NUMA_CMD="${NUMA} ${ACCUMULO_NUMACTL_OPTIONS}" + else + export NUMA_CMD="" fi + fi - # We want the files to be consistently named with the log files - # server_identifier_hostname.{out,err}, e.g. tserver_2_fqdn.out - OUTFILE="${ACCUMULO_LOG_DIR}/${S}_${t}_${loghost}.out" - ERRFILE="${ACCUMULO_LOG_DIR}/${S}_${t}_${loghost}.err" + # We want the files to be consistently named with the log files + # server_identifier_hostname.{out,err}, e.g. tserver_2_fqdn.out + OUTFILE="${ACCUMULO_LOG_DIR}/${S}_${t}_${loghost}.out" + ERRFILE="${ACCUMULO_LOG_DIR}/${S}_${t}_${loghost}.err" - # Rotate the .out and .err files - rotate_log "$OUTFILE" ${ACCUMULO_NUM_OUT_FILES} - rotate_log "$ERRFILE" ${ACCUMULO_NUM_OUT_FILES} + # Rotate the .out and .err files + rotate_log "$OUTFILE" "${ACCUMULO_NUM_OUT_FILES}" + rotate_log "$ERRFILE" "${ACCUMULO_NUM_OUT_FILES}" - # Fork the process, store the pid - nohup ${NUMA_CMD} "$COMMAND" "${service}" --address "${address}" >"$OUTFILE" 2>"$ERRFILE" < /dev/null & - echo $! > ${PID_FILE} + # Fork the process, store the pid + nohup ${NUMA_CMD} "$COMMAND" "${service}" --address "${address}" >"$OUTFILE" 2>"$ERRFILE" < /dev/null & + echo $! > "${PID_FILE}" - done + done fi # Check the max open files limit and selectively warn MAX_FILES_OPEN=$(ulimit -n) if [[ -n $MAX_FILES_OPEN ]] ; then - MAX_FILES_RECOMMENDED=${MAX_FILES_RECOMMENDED:-32768} - if (( MAX_FILES_OPEN < MAX_FILES_RECOMMENDED )) - then - echo "WARN : Max open files on $host is $MAX_FILES_OPEN, recommend $MAX_FILES_RECOMMENDED" >&2 - fi + MAX_FILES_RECOMMENDED=${MAX_FILES_RECOMMENDED:-32768} + if (( MAX_FILES_OPEN < MAX_FILES_RECOMMENDED )) + then + echo "WARN : Max open files on $host is $MAX_FILES_OPEN, recommend $MAX_FILES_RECOMMENDED" >&2 + fi fi } @@ -193,10 +193,10 @@ function stop_service() { signal=$3 for pid_file in ${ACCUMULO_PID_DIR}/accumulo-${ACCUMULO_IDENT_STRING}-${service}*.pid; do - if [[ -f ${pid_file} ]]; then + if [[ -f "${pid_file}" ]]; then echo "Stopping $service on $host"; - kill -s "$signal" `cat ${pid_file}` 2>/dev/null - rm -f ${pid_file} 2>/dev/null + kill -s "$signal" "$(cat "${pid_file}")" 2>/dev/null + rm -f "${pid_file}" 2>/dev/null fi done } @@ -221,10 +221,10 @@ function main() { case "$1" in start) - start_service ${*:2} + start_service "${@:2}" ;; stop) - stop_service ${*:2} + stop_service "${@:2}" ;; *) invalid_args "'$1' is an invalid <command>" http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e3b62a8/assemble/libexec/tool.sh ---------------------------------------------------------------------- diff --git a/assemble/libexec/tool.sh b/assemble/libexec/tool.sh index 065ef6e..fe482be 100755 --- a/assemble/libexec/tool.sh +++ b/assemble/libexec/tool.sh @@ -36,12 +36,12 @@ if [[ -z "$ZOOKEEPER_HOME" ]] ; then exit 1 fi -ZOOKEEPER_CMD='ls -1 $ZOOKEEPER_HOME/zookeeper-[0-9]*[^csn].jar ' -if [[ $(eval $ZOOKEEPER_CMD | wc -l) -ne 1 ]] ; then +ZOOKEEPER_CMD="ls -1 $ZOOKEEPER_HOME/zookeeper-[0-9]*[^csn].jar " +if [[ $(eval "$ZOOKEEPER_CMD" | wc -l) -ne 1 ]] ; then echo "Not exactly one zookeeper jar in $ZOOKEEPER_HOME" exit 1 fi -ZOOKEEPER_LIB=$(eval $ZOOKEEPER_CMD) +ZOOKEEPER_LIB=$(eval "$ZOOKEEPER_CMD") LIB="$ACCUMULO_LIB_DIR" CORE_LIB="$LIB/accumulo-core.jar" @@ -88,5 +88,5 @@ fi #echo USERJARS=$USERJARS #echo CLASSNAME=$CLASSNAME #echo HADOOP_CLASSPATH=$HADOOP_CLASSPATH -#echo exec "$HADOOP_PREFIX/bin/hadoop" jar "$TOOLJAR" $CLASSNAME -libjars \"$LIB_JARS\" $ARGS -exec "$HADOOP_PREFIX/bin/hadoop" jar "$TOOLJAR" $CLASSNAME -libjars \"$LIB_JARS\" "$@" +#echo exec "$HADOOP_PREFIX/bin/hadoop" jar "$TOOLJAR" "$CLASSNAME" -libjars \"$LIB_JARS\" $ARGS +exec "$HADOOP_PREFIX/bin/hadoop" jar "$TOOLJAR" "$CLASSNAME" -libjars "$LIB_JARS" "$@"