blob: 05bb2cfb53006c7efa558b5908d59206aaee4e03 [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: trafodion_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 environment setup ($timestamp)"
#==============================================
# display license text and get acceptance
echo "=== $timestamp ==="
if [ "$ACCEPT_LICENSE" != "Y" ]; then
cat $( cd "$( dirname "$0" )" && pwd )/trafodion_license
echo -n "BY TYPING \"ACCEPT\" YOU AGREE TO THE TERMS OF THIS AGREEMENT: "
read answer
if [ "$answer" != "accept" ] && [ "$answer" != "ACCEPT" ] && [ "$answer" != "Accept" ]; then
echo "***ERROR: You must accept this license by typing \"accept\" to install."
exit -1
fi
fi
#============================
# check that we are running from a userid with sudo access
sudo echo "***INFO: testing sudo access"
if [ $? -ne 0 ]; then
echo "***ERROR: This script must be run from userid with sudo access."
exit -1
fi
#================================
# make sure the user didn't specify the sudo userid as the Trafodion userid
# because we rewrite the .bashrc file and don't want to mess up the user's
# current environment
if [ "$USER" == "$TRAF_USER" ]; then
echo "***ERROR: The Trafodion username cannot be the same as the install username"
exit -1
fi
#================================
#installing required packages"
$LOCAL_WORKDIR/traf_package_setup
if [ $? != 0 ]; then
echo "***ERROR: Error installing required packages"
exit -1
fi
#================================
# Set some limits needed by Trafodion
TRAF_LIMITS_CONF="$TRAF_WORKDIR/trafodion.conf"
sudo rm $TRAF_WORKDIR/trafodion.conf &>/dev/null
echo "***INFO: modifying limits in $TRAF_LIMITS_CONF on all nodes"
# append Trafodion settings to end of file
echo "# Trafodion settings" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER soft core unlimited" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER hard core unlimited" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER soft memlock unlimited" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER hard memlock unlimited" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER soft nofile 32768" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER hard nofile 65536" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER soft nproc 100000" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER hard nproc 100000" >> $TRAF_LIMITS_CONF
echo "hbase soft nofile 8192" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER soft nofile 8192" >> $TRAF_LIMITS_CONF
echo "$TRAF_USER hard nofile 65535" >> $TRAF_LIMITS_CONF
# copy to all nodes
if [ $all_node_count -eq 1 ]; then
sudo cp $TRAF_LIMITS_CONF /etc/security/limits.d/trafodion.conf
if [ $? != 0 ]; then
echo "***ERROR: unable to copy $TRAF_LIMITS_CONF to /etc/security/limits.d/trafodion.conf"
exit -1
fi
else
$TRAF_PDCP $TRAF_LIMITS_CONF $TRAF_LIMITS_CONF
if [ $? != 0 ]; then
echo "***ERROR: unable to copy $TRAF_LIMITS_CONF to all nodes"
exit -1
fi
$TRAF_PDSH sudo cp $TRAF_LIMITS_CONF /etc/security/limits.d/trafodion.conf
if [ $? != 0 ]; then
echo "***ERROR: unable to copy $TRAF_LIMITS_CONF to /etc/security/limits.d/trafodion.conf on all nodes"
exit -1
fi
fi
#=======================================
echo "***INFO: create Trafodion userid \"$TRAF_USER\" "
$LOCAL_WORKDIR/traf_add_user
if [ $? != 0 ]; then
echo "***ERROR: Unable to create Trafodion userid: $TRAF_USER"
exit -1
fi
#=======================================