blob: f22baeeb9d5d530acb982ffaebcafcca20da9729 [file] [log] [blame]
#!/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 Trafodion environment on a Cluster System
#==============================================
timestamp=$(date +%F-%H-%M-%S)
source /etc/trafodion/trafodion_config
cd $LOCAL_WORKDIR
echo "***Log File: traf_package_setup script***" >> $INSTALL_LOG
echo >> $INSTALL_LOG
echo "Username: $TRAF_USER" >> $INSTALL_LOG
echo "Nodes: $NODE_LIST" >> $INSTALL_LOG
echo "Home directory: $HOME_DIR" >> $INSTALL_LOG
echo >> $INSTALL_LOG
echo "***INFO: Starting Trafodion Package Setup ($timestamp)"
#========================================
echo "***INFO: Installing required packages"
echo "***INFO: Log file located in /var/log/trafodion"
YUM_LOG=/var/log/trafodion/trafodion_yum_$timestamp.log
ZYPP_LOG=/var/log/trafodion/trafodion_zypp_$timestamp.log
#===============================
#Set internet access
internetAccess="true"
#================================
#Checking to see if epel package is installed.
if [[ $SUSE_LINUX == "false" ]]; then
for node in $ALL_NODE_LIST;
do
EPEL_INSTALLED=$(ssh -q -n $node rpm -qa | grep epel | wc -l)
if [[ $EPEL_INSTALLED == 0 ]]; then
break;
fi
done
if [[ $EPEL_INSTALLED == 0 ]]; then
echo "***INFO: ... EPEL rpm"
epel_rpm="epel-release-6-8.noarch.rpm"
echo "***INFO: Downloading EPEL repo, since not installed."
sudo yum --assumeyes install wget 2>> $YUM_LOG >> $YUM_LOG
wget http://download.fedoraproject.org/pub/epel/6/x86_64/$epel_rpm
if [ $? != 0 ]; then
echo "***ERROR: Can't download EPEL rpm $epel_rpm"
echo "***ERROR: Will need to download and install EPEL rpm on each node of cluster"
echo
exit -1
fi
if [ $all_node_count -ne 1 ]; then
for node in $ALL_NODE_LIST
do
scp -q $LOCAL_WORKDIR/$epel_rpm $(whoami)@$node:$HOME
if [[ $? -gt 1 ]]; then
echo "***ERROR: Unable to find $EPEL_RPM or unable to copy."
exit -1
fi
done
else
cp -rf $epel_rpm $HOME
fi
fi
for node in $ALL_NODE_LIST;
do
EPEL_INSTALLED=$( ssh -q -n $node rpm -qa | grep epel | wc -l)
if [[ $EPEL_INSTALLED == 0 ]]; then
ssh -q -n $node sudo rpm -Uvh $HOME/epel* 2>> $YUM_LOG >> $YUM_LOG
if [ $? != 0 ]; then
echo "***ERROR: Can't install EPEL rpm $EPEL_RPM"
exit -1
fi
fi
done
else
echo
echo
echo
echo "***WARNING: This system is using SUSE Linux"
echo "***WARNING: pdsh must be installed prior to installing Trafodion."
echo "***WARNING: If pdsh has not been installed. Please stop the installer and install pdsh"
echo
echo
sleep 10
fi
#install pdsh if not on SUSE Linux
if [[ $SUSE_LINUX == "false" ]]; then
if [ $all_node_count -ne 1 ]; then
for node in $ALL_NODE_LIST
do
echo "***INFO: ... pdsh on node $node"
#if not already installed on this node, then install it
ssh -q -n $node rpm -qa | grep pdsh &> /dev/null
if [ $? -ne 0 ]; then
ssh -q -n $node sudo mkdir -p $TRAF_WORKDIR
ssh -q -n $node sudo mkdir -p /var/log/trafodion
if [[ $internetAccess == "true" ]]; then
ssh -q -n $node sudo yum --assumeyes install pdsh >> $YUM_LOG
if [ $? != 0 ]; then
echo "***ERROR: Can't install pdsh on node $node"
exit -1
fi
else
echo "***ERROR: Can't install pdsh on node $node"
echo "***ERROR: Must have pdsh installed on each node."
echo "***ERROR: No internet access to do automatic install."
exit -1
fi
fi
done
# create working directory on all nodes
$TRAF_PDSH sudo mkdir -p $TRAF_WORKDIR &> /dev/null
$TRAF_PDSH sudo chmod -R 777 $TRAF_WORKDIR
$TRAF_PDSH mkdir -p /var/log/trafodion &> /dev/null
fi
fi
$TRAF_PDSH sudo mkdir -p $TRAF_WORKDIR
$TRAF_PDSH sudo chmod 777 $TRAF_WORKDIR
if [[ $SUSE_LINUX == "false" ]]; then
# to handle the case where the EPEL rpm was already
# installed but disabled, we enable it here
# it doesn't hurt if it was already enabled and we try to enable it again
$TRAF_PDSH sudo yum-config-manager --enable RedHat-6-x86_64-Fedora-EPEL 2>> $YUM_LOG >> $YUM_LOG
package_list="apr apr-util sqlite expect perl-DBD-SQLite* protobuf xerces-c perl-Params-Validate perl-Time-HiRes gzip lzo lzop unzip gcc-c++ unixODBC unixODBC-devel libiodbc libiodbc-devel"
if [[ $internetAccess == "true" ]]; then
for package in $package_list
do
echo "***INFO: Checking if $package is installed ..."
for node in $ALL_NODE_LIST
do
installed=`ssh -q -n $node sudo rpm -qa | grep $package | wc -l`
if [[ $installed -eq "0" ]]; then
echo "***INFO: Installing $package on all nodes"
ssh -q -n $node sudo yum --assumeyes install $package 2>> $YUM_LOG >> $YUM_LOG
if [ $? != 0 ]; then
echo "***ERROR: Can't install $package"
exit -1
fi
fi
done
done
else
for node in $ALL_NODE_LIST
do
echo "***ERROR: No internet access on $node"
echo "***ERROR: Missing packages will need to be installed."
echo "***ERROR: Missing packages: "
for package in $package_list
do
installed=$(sudo rpm -qa | grep $package | wc -l)
if [[ $installed -eq "0" ]]; then
echo "$package"
stopInstall=true
fi
done
done
if [[ $stopInstall == "true" ]]; then
exit -1
fi
fi
else
echo
echo
echo "***WARNING: All needed RPM's must be installed in advance to install Trafodion on SUSE."
echo "***WARNING: sqlite expect perl-DBD-SQLite* protobuf xerces-c perl-Params-Validate perl-Time-HiRes gzip"
echo "***WARNING: If any of these packages have not been installed. Stop Trafodion installation and install."
echo
echo
sleep 10
fi