| #!/bin/bash |
| # @@@ START COPYRIGHT @@@ |
| # |
| # 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. |
| # |
| # @@@ END COPYRIGHT @@@ |
| |
| |
| # Setup Hortonworks/Ambari |
| |
| #============================================== |
| # Default values |
| typeset TRAF_WORKDIR="$( cd "$( dirname "$0" )" && pwd )/.." |
| typeset timestamp=$(date +%F-%H-%M-%S) |
| typeset SETUP_LOG="/var/log/trafodion/traf_ambari_setup_$timestamp.log" |
| |
| AMBARI=$(rpm -qa | grep ambari | wc -l) |
| #============================================== |
| |
| function print_usage { |
| cat << EOF |
| This script will help install Hortonworks/Ambari. |
| |
| NOTE: Please refer to Hortonworks documentation for questions. |
| |
| Usage: $(basename $0) [options] |
| |
| Options: |
| --help Print this message and exit. |
| EOF |
| } |
| |
| #============================================== |
| # Parse input parameters |
| while [[ $# -gt 0 ]]; do |
| case "$1" in |
| --help) |
| print_usage |
| exit -1 |
| ;; |
| *) |
| echo "***ERROR: unknown parameter '$1'" |
| print_usage |
| exit -1 |
| esac |
| shift |
| done |
| |
| #============================================== |
| #Info for log file |
| sudo mkdir -p /var/log/trafodion |
| sudo chmod 777 /var/log/trafodion |
| |
| SUSE_Installed=$(grep -cr SUSE /proc/version) |
| |
| |
| echo "***INFO: Log file located /var/log/trafodion" |
| echo "***Log File: trafodion_ambari_setup script***" >> $SETUP_LOG |
| echo >> $SETUP_LOG |
| echo "Working directory: $TRAF_WORKDIR" >> $SETUP_LOG |
| echo >> $SETUP_LOG |
| |
| #============================================== |
| if [[ $AMBARI -eq 0 ]]; then |
| echo "***INFO: Installing Hortonworks/Ambari, will need browser access to complete" | tee -a $SETUP_LOG |
| |
| sudo rm -rf ambari.repo* 2>/dev/null |
| if [[ "$SUSE_Installed" -eq "1" ]]; then |
| wget http://public-repo-1.hortonworks.com/ambari/suse11/2.x/updates/2.0.0/ambari.repo |
| else |
| wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.4.0.1/ambari.repo |
| fi |
| |
| if [ $? -ne 0 ]; then |
| echo "***ERROR: Time out error. Please check http_proxy settings." | tee -a $SETUP_LOG |
| echo "***ERROR: Exiting..." | tee -a $SETUP_LOG |
| echo |
| exit -1 |
| fi |
| |
| if [[ "$SUSE_Installed" -eq "1" ]]; then |
| sudo cp ambari.repo /etc/zypp/repos.d |
| sudo zypper install ambari-server |
| else |
| sudo cp ambari.repo /etc/yum.repos.d |
| sudo yum --assumeyes install ambari-server |
| fi |
| sudo ambari-server setup |
| sudo ambari-server start |
| |
| if [ $? -ne 0 ]; then |
| echo "***ERROR: Error while installing Hortonworks/Ambari" | tee -a $SETUP_LOG |
| echo "***ERROR: Exiting..." | tee -a $SETUP_LOG |
| echo |
| exit -1 |
| fi |
| |
| echo "***INFO: Complete Hortonworks/Ambari setup from http://localhost:8080" | tee -a $SETUP_LOG |
| else |
| echo |
| echo "***INFO: Hortonworks/Ambari previously installed." | tee -a $SETUP_LOG |
| |
| fi |
| #============================================== |