| #! /usr/bin/env bash |
| |
| # Copyright 2014 Uno authors (see AUTHORS) |
| # |
| # Licensed 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 |
| |
| source "$bin"/impl/load-env.sh "$1" |
| source "$UNO_HOME"/bin/impl/util.sh |
| |
| case "$1" in |
| fetch) |
| hash mvn 2>/dev/null || { echo >&2 "Maven must be installed & on PATH. Aborting."; exit 1; } |
| hash wget 2>/dev/null || { echo >&2 "wget must be installed & on PATH. Aborting."; exit 1; } |
| if [[ "$2" == "all" ]]; then |
| "$bin"/impl/fetch.sh fluo && \ |
| "$bin"/impl/fetch.sh spark && \ |
| "$bin"/impl/fetch.sh metrics |
| else |
| "$bin"/impl/fetch.sh "$2" "$3" |
| fi |
| ;; |
| setup) |
| case "$2" in |
| all) |
| "$bin"/impl/setup-fluo.sh |
| "$bin"/impl/setup-spark.sh |
| "$bin"/impl/setup-metrics.sh |
| ;; |
| accumulo) |
| "$bin"/impl/setup-accumulo.sh "$3" |
| ;; |
| fluo) |
| "$bin"/impl/setup-fluo.sh "$3" |
| ;; |
| fluo-yarn) |
| "$bin"/impl/setup-fluo-yarn.sh "$3" |
| ;; |
| spark) |
| "$bin"/impl/setup-spark.sh |
| ;; |
| metrics) |
| "$bin"/impl/setup-metrics.sh |
| ;; |
| *) |
| echo "Usage: uno setup <component> [--no-deps]" |
| echo -e "\nPossible components:\n" |
| echo " all Sets up all of the following components" |
| echo " accumulo Sets up Apache Accumulo and its dependencies (Hadoop & Zookeeper)" |
| echo " spark Sets up Apache Spark" |
| echo " fluo Sets up Apache Fluo and its dependencies (Accumulo, Hadoop, & Zookeeper)" |
| echo " fluo-yarn Sets up Apache Fluo YARN and its dependencies (Fluo, Accumulo, Hadoop, & Zookeeper)" |
| echo -e " metrics Sets up metrics service (InfluxDB + Grafana)\n" |
| echo "Options:" |
| echo " --no-deps Dependencies will be setup unless this option is specified. Only works for fluo & accumulo components." |
| exit 1 |
| ;; |
| esac |
| ;; |
| kill) |
| "$bin"/impl/kill.sh "${@:2}" |
| ;; |
| ashell) |
| check_dirs ACCUMULO_HOME |
| "$ACCUMULO_HOME"/bin/accumulo shell -u "$ACCUMULO_USER" -p "$ACCUMULO_PASSWORD" "${@:2}" |
| ;; |
| start) |
| "$bin"/impl/start.sh "${@:2}" |
| ;; |
| stop) |
| "$bin"/impl/stop.sh "${@:2}" |
| ;; |
| env) |
| "$bin"/impl/print-env.sh "${@:2}" |
| ;; |
| version) |
| "$bin"/impl/version.sh "${@:2}" |
| ;; |
| *) |
| echo -e "Usage: uno <command> (<argument>)\n" |
| echo -e "Possible commands:\n" |
| echo " fetch <component> Fetches binary tarballs of component and it dependencies by either building or downloading" |
| echo " the tarball (as configured by uno.conf). Run 'uno fetch all' to fetch all binary tarballs." |
| echo " Run 'uno fetch' for a list of possible components." |
| echo " setup <component> Sets up component and its dependencies (clearing any existing data)" |
| echo " Run 'uno setup' for list of components." |
| echo " start <component> Start Zookeeper, Hadoop, Accumulo, if not running." |
| echo " stop <component> Stop Accumulo, Hadoop, Zookeeper, if running." |
| echo " kill Kills all software" |
| echo " ashell Runs the Accumulo shell" |
| echo " env Prints out shell configuration for PATH and common environment variables." |
| echo " Add '--paths' or '--vars' command to limit what is printed." |
| echo " version <dep> Prints out configured version for dependency" |
| echo " " |
| exit 1 |
| esac |