blob: 85f45b30371ae6a4b2d81a30281be27357178e86 [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 @@@
# Create the sqconfig file
#=================================================
TRAF_CONFIG="/etc/trafodion/trafodion_config"
source $TRAF_CONFIG
typeset TRAF_USER_DIR="$HOME_DIR/$TRAF_USER"
typeset TRAF_GROUP="trafodion"
#================================================
#=================================================
# Create initial sqconfig file only if we have more than one node.
# If only one node, then we'll use the sqconfig included in the Trafodion build
echo "***INFO: creating sqconfig file"
sqconfig=$LOCAL_WORKDIR/sqconfig_${HOSTNAME}_${TRAF_USER}
rm $sqconfig &> /dev/null
cores=$(lscpu | grep "CPU(s) list" | awk '{print $4}' | sed -e "s@,@-@" )
maxCores=`echo $cores | sed 's/.*\-//'`
if [[ "$maxCores" -gt "255" ]]; then
cores="0-255"
fi
processors=$(lscpu | grep "Socket(s)" | awk '{print $2}')
# On some VMs it seems that "Socket(s)" is not listed in
# lscpu so, we will default processors=1 in that case
if [ "$processors" == "" ]; then
processors=$(lscpu | grep "CPU socket(s)" | awk '{print $3}')
if [ "$processors" == "" ]; then
echo "***WARNING: unable to determine number of sockets with 'lscpu'..."
echo "***WARNING: ...defaulting sqconfig 'processors=1'"
processors="1"
fi
fi
sudo chmod 777 $TRAF_CONFIG
sed -i '/CORES\=/d' $TRAF_CONFIG
echo "export CORES=\"$cores\"" >> $TRAF_CONFIG
sed -i '/PROCESSORS\=/d' $TRAF_CONFIG
echo "export PROCESSORS=\"$processors\"" >> $TRAF_CONFIG
sudo chmod 777 $TRAF_CONFIG
echo "#" > $sqconfig
echo "begin node" >> $sqconfig
node_id=0
for node in $NODE_LIST
do
echo "node-id=$node_id;node-name=$node;cores=$cores;processors=$processors;roles=connection,aggregation,storage" >> $sqconfig
((node_id++))
done
echo "end node" >> $sqconfig
#Can be added back later
##This sed is dependent on the nubmer of line in the Apahce copyright. If it get larger this needs to change.
#sed '1,21d' $LOCAL_WORKDIR/sqconfig_persist.txt >> $sqconfig
sudo cp $sqconfig $UNTAR_DIR
sudo cp $sqconfig $TRAF_USER_DIR/sqconfig
sudo chown $TRAF_USER.$TRAF_GROUP $TRAF_USER_DIR/sqconfig