2008-06-20 17:51:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# This script is used for RMC node configuration
|
|
|
|
# usage:
|
|
|
|
# To add node to the cluster:
|
2008-06-24 20:45:27 +00:00
|
|
|
# NODE=nodename NODEID=fbb5ec1f64dd299c \
|
2008-08-06 18:14:52 +00:00
|
|
|
# MONMASTER=msname_or_ip MS_NODEID=fbb5ec1f64dd299c \
|
2008-06-20 17:51:55 +00:00
|
|
|
# configrmcnode 1
|
|
|
|
# To remove node to the cluster
|
|
|
|
# NODE=nodename configrmcnode -1
|
|
|
|
##########################################################################################
|
2008-06-25 14:50:11 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
ADD=$1
|
|
|
|
else
|
|
|
|
ADD=1
|
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
|
2008-10-17 13:41:14 +00:00
|
|
|
if [ -z "$NODE" ]; then
|
|
|
|
NODE=`hostname`
|
|
|
|
fi
|
|
|
|
|
2012-06-01 08:08:06 +00:00
|
|
|
#logger -t xCAT -p local4.info "configrmcnode: ADD=$ADD, NODE=$NODE, NODEID=$NODEID MONMASTER=$MONMASTER,MS_NODEID=$MS_NODEID"
|
2008-06-20 17:51:55 +00:00
|
|
|
|
|
|
|
#check if rsct is installed and running
|
|
|
|
if [ ! -e /usr/bin/lsrsrc ]; then
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "RMC setup on node $NODE: RSCT is not is not installed."
|
2008-06-20 17:51:55 +00:00
|
|
|
exit 1;
|
2008-10-20 17:49:38 +00:00
|
|
|
else
|
|
|
|
PID=`/bin/ps -ef | /bin/grep rmcd | /bin/grep -v grep | /bin/awk '{print $2}'`
|
|
|
|
if [ -z "$PID" ]; then
|
|
|
|
result=`/usr/sbin/rsct/bin/rmcctrl -s 2>&1`;
|
|
|
|
if [ $? -gt 0 ]; then
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "RMC deamon cannot be started on node $NODE:$result"
|
2008-10-20 17:49:38 +00:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#wait for RMC daemon to fully functional
|
|
|
|
RETRY_LIMIT=10 # number of 2 second retry intervals (20 second total)
|
|
|
|
let i=$RETRY_LIMIT
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
lsrsrc > /dev/null 2>&1
|
|
|
|
rc=$?
|
|
|
|
if [[ $rc -eq 0 ]]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
i=$((i - 1))
|
|
|
|
if (( i > 0 ))
|
|
|
|
then
|
|
|
|
sleep 2
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ $rc -ne 0 ]]
|
|
|
|
then
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "RMC subsystem has not started"
|
2008-10-20 17:49:38 +00:00
|
|
|
exit 1
|
2008-06-20 17:51:55 +00:00
|
|
|
fi
|
2008-10-20 17:49:38 +00:00
|
|
|
|
2009-06-12 19:20:00 +00:00
|
|
|
if [ $ADD -eq 1 ]; then
|
|
|
|
#check if the resource is defined
|
|
|
|
result=`/usr/bin/lsrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID"::MNName 2>&1`
|
|
|
|
if [ $? -gt 0 ]; then #node defined
|
|
|
|
#ask RMC take the new nodeid
|
|
|
|
if [[ $NODEID != "" ]]; then
|
|
|
|
oldid=`/usr/sbin/rsct/bin/lsnodeid`
|
|
|
|
oldidU=`echo "$oldid" | awk '{ print toupper($1) }'`
|
|
|
|
newidU=`echo "$NODEID" | awk '{ print toupper($1) }'`
|
|
|
|
if [ $oldidU != $newidU ]; then
|
|
|
|
if [ -e /usr/sbin/rsct/install/bin/recfgctnid ]; then
|
|
|
|
result=`/usr/sbin/rsct/install/bin/recfgctnid $NODEID 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Reset nodeid: $result"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.info "Reset nodeid: $result"
|
2009-06-12 19:20:00 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
#stop all rmc daemons
|
|
|
|
/usr/sbin/rsct/bin/rmcctrl -z
|
|
|
|
|
|
|
|
#get new nodeid into id files
|
|
|
|
if [ -e /var/ct/cfg/ct_node_id ]; then
|
|
|
|
sed s/^[^\#].*$/$NODEID/ /var/ct/cfg/ct_node_id > /tmp/id.tmp
|
|
|
|
else
|
|
|
|
if [ -e /etc/ct_node_id ]; then
|
|
|
|
sed s/^[^\#].*$/$NODEID/ /etc/ct_node_id > /tmp/id.tmp
|
|
|
|
else
|
|
|
|
echo $NODEID > /tmp/id.tmp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
cp /tmp/id.tmp /var/ct/cfg/ct_node_id
|
|
|
|
cp /tmp/id.tmp /etc/ct_node_id
|
|
|
|
rm /tmp/id.tmp
|
|
|
|
|
|
|
|
#reconfig RMC
|
|
|
|
result=`/usr/sbin/rsct/install/bin/recfgct -s 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.warning "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
|
2009-06-12 19:20:00 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
PID=`/bin/ps -ef | /bin/grep rmcd | /bin/grep -v grep | /bin/awk '{print $2}'`
|
|
|
|
if [ -z "$PID" ]; then
|
|
|
|
#restart rmc daemon
|
|
|
|
result=`/usr/sbin/rsct/bin/rmcctrl -s 2>&1`;
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
echo "RMC deamon cannot be started on node $NODE:$result"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "RMC deamon cannot be started on node $NODE:$result"
|
2009-06-12 19:20:00 +00:00
|
|
|
exit 1;
|
|
|
|
fi
|
2008-08-06 18:14:52 +00:00
|
|
|
fi
|
2008-06-24 20:45:27 +00:00
|
|
|
|
2009-06-12 19:20:00 +00:00
|
|
|
#wait for RMC daemon to fully functional
|
|
|
|
RETRY_LIMIT=20 # number of 2 second retry intervals (40 second total)
|
|
|
|
let i=$RETRY_LIMIT
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
lsrsrc > /dev/null 2>&1
|
|
|
|
rc=$?
|
|
|
|
if [[ $rc -eq 0 ]]
|
|
|
|
then
|
|
|
|
break
|
2008-08-06 18:14:52 +00:00
|
|
|
fi
|
2008-06-27 14:35:20 +00:00
|
|
|
|
2009-06-12 19:20:00 +00:00
|
|
|
i=$((i - 1))
|
|
|
|
if (( i > 0 ))
|
|
|
|
then
|
|
|
|
sleep 2
|
2008-08-06 18:14:52 +00:00
|
|
|
else
|
2009-06-12 19:20:00 +00:00
|
|
|
break
|
2008-08-06 18:14:52 +00:00
|
|
|
fi
|
2009-06-12 19:20:00 +00:00
|
|
|
done
|
|
|
|
if [[ $rc -ne 0 ]]
|
|
|
|
then
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "RMC subsystem has not started"
|
2009-06-12 19:20:00 +00:00
|
|
|
exit 1
|
2008-08-06 18:14:52 +00:00
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
|
2009-06-12 19:20:00 +00:00
|
|
|
#enable remote client connection
|
|
|
|
/usr/sbin/rsct/bin/rmcctrl -p; /usr/bin/refrsrc IBM.MCP
|
|
|
|
|
|
|
|
#get IP address of MS
|
|
|
|
ms_ip=$MONMASTER
|
|
|
|
result=`ping -c1 $MONMASTER 2>&1`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
index1=`expr index "$result" "\("`
|
|
|
|
index2=`expr index "$result" "\)"`
|
|
|
|
#ms_ip=${result:$index1+1:$index2-$index1-2}
|
|
|
|
pos=`expr $index1 + 1`
|
|
|
|
length=`expr $index2 - $index1`
|
|
|
|
length=`expr $length - 1`
|
|
|
|
ms_ip=`expr substr "$result" $pos $length`
|
|
|
|
else
|
|
|
|
echo "RMC setup on node $NODE:$result"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.info "RMC setup on node $NODE:$result"
|
2009-06-12 19:20:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#define resource in IBM.MCP class on node
|
|
|
|
result1=`/usr/bin/mkrsrc-api IBM.MCP::MNName::"$NODE"::KeyToken::"$MONMASTER"::IPAddresses::"{\"$ms_ip\"}"::NodeID::0x$MS_NODEID 2>&1`
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
echo "Define resource in IBM.MCP class on node $NODE. result=$result1"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "Define resource in IBM.MCP class on node $NODE. result=$result1"
|
2009-06-12 19:20:00 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-11-22 04:01:31 +00:00
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
|
2010-12-16 17:01:03 +00:00
|
|
|
#create predefined resources
|
2009-06-12 19:20:00 +00:00
|
|
|
if [[ -z "$NFSSERVER" ]]; then
|
|
|
|
NFSSERVER=$MASTER
|
2008-06-24 20:45:27 +00:00
|
|
|
fi
|
2012-07-19 06:57:13 +00:00
|
|
|
|
|
|
|
if [ -f /opt/xcat/xcatinfo ]; then
|
|
|
|
INSTALLDIR=`grep 'INSTALLDIR' /opt/xcat/xcatinfo |cut -d= -f2`
|
|
|
|
fi
|
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
|
|
|
|
2010-12-16 17:01:03 +00:00
|
|
|
nodetype="node"
|
|
|
|
if [[ $NTYPE = service ]]; then
|
|
|
|
nodetype=sn
|
|
|
|
fi
|
|
|
|
|
2009-06-12 19:20:00 +00:00
|
|
|
mkdir -p /var/xcat/rmcmon
|
2011-01-25 20:51:07 +00:00
|
|
|
rm -f -R /var/xcat/rmcmon/*
|
2009-10-05 20:12:42 +00:00
|
|
|
if [[ $OSTYPE = linux* ]]; then
|
2012-07-19 06:57:13 +00:00
|
|
|
mkdir -p /tmp/postage/
|
|
|
|
rm -f -R /tmp/postage/rmcmon/*
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 -nH --cut-dirs=2 --reject "index.html*" --no-parent http://$NFSSERVER$INSTALLDIR/postscripts/rmcmon/scripts -P /tmp/postage/ 2> /tmp/wget.log
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 -nH --cut-dirs=2 --reject "index.html*" --no-parent http://$NFSSERVER$INSTALLDIR/postscripts/rmcmon/resources/$nodetyp -P /tmp/postage/ 2> /tmp/wget.log
|
|
|
|
mv /tmp/postage/rmcmon/* /var/xcat/rmcmon;
|
|
|
|
rm -rf /tmp/postage/rmcmon/
|
2009-10-05 20:12:42 +00:00
|
|
|
else
|
|
|
|
mkdir -p /xcatmnt
|
2011-10-24 10:43:57 +00:00
|
|
|
if [[ $USENFSV4ONAIX = yes ]] || [[ $USENFSV4ONAIX = 1 ]] || [[ $USENFSV4ONAIX = Yes ]] || [[ $USENFSV4ONAIX = YES ]] || [[ $USENFSV4ONAIX = Y ]] || [[ $USENFSV4ONAIX = y ]]; then
|
|
|
|
result=`mount -o vers=4 $NFSSERVER:/install/postscripts /xcatmnt`
|
|
|
|
else
|
|
|
|
result=`mount $NFSSERVER:/install/postscripts /xcatmnt`
|
|
|
|
fi
|
2009-10-05 20:12:42 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
echo "Failed to mount:$result"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "Failed to mount $result"
|
2009-10-05 20:12:42 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2010-12-16 17:01:03 +00:00
|
|
|
mkdir -p /var/xcat/rmcmon/scripts
|
2011-01-19 15:43:16 +00:00
|
|
|
cp -p -R /xcatmnt/rmcmon/scripts/* /var/xcat/rmcmon/scripts/ 2>/dev/null
|
2010-12-16 17:01:03 +00:00
|
|
|
mkdir -p /var/xcat/rmcmon/resources/$nodetype
|
2011-01-19 15:43:16 +00:00
|
|
|
cp -p -R /xcatmnt/rmcmon/resources/$nodetype/* /var/xcat/rmcmon/resources/$nodetype/ 2>/dev/null
|
2009-10-05 20:12:42 +00:00
|
|
|
umount /xcatmnt
|
|
|
|
rmdir /xcatmnt
|
|
|
|
fi
|
2011-11-08 19:20:47 +00:00
|
|
|
chmod 755 /var/xcat/rmcmon/scripts/*
|
|
|
|
if [ -d /var/xcat/rmcmon/resources/$nodetype ]; then
|
|
|
|
/var/xcat/rmcmon/scripts/mkrmcresources /var/xcat/rmcmon/resources/$nodetype
|
|
|
|
fi
|
2009-06-12 19:20:00 +00:00
|
|
|
else
|
|
|
|
#check if the resource is defined
|
|
|
|
result=`/usr/bin/lsrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID"::MNName 2>&1`
|
2008-06-20 17:51:55 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
2009-06-12 19:20:00 +00:00
|
|
|
# echo $result
|
|
|
|
p="2612-023" #resource not found
|
|
|
|
result1=`awk -v a="$result" -v b="$p" 'BEGIN{print index(a,b)}'`
|
|
|
|
if [ $result1 -gt 0 ]; then
|
|
|
|
if [ $ADD -eq -1 ]; then
|
|
|
|
exit 0; #resource already removed, do nothing
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "$result"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "$result"
|
2009-06-12 19:20:00 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
fi
|
2008-06-21 21:12:33 +00:00
|
|
|
|
2008-06-20 17:51:55 +00:00
|
|
|
#remove resource in IBM.MCP class on the node
|
2008-08-06 18:14:52 +00:00
|
|
|
result2=`/usr/bin/rmrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID" 2>&1`
|
2008-06-20 17:51:55 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "Remove resource in IBM.MCP class on noderesult=$result2"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.err "Remove resource in IBM.MCP class on noderesult=$result2"
|
2008-06-20 17:51:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2009-06-12 19:20:00 +00:00
|
|
|
|
2008-11-22 04:01:31 +00:00
|
|
|
echo "done"
|
2012-06-01 08:08:06 +00:00
|
|
|
logger -t xCAT -p local4.info "done"
|
2008-06-20 17:51:55 +00:00
|
|
|
exit 0;
|
|
|
|
|
|
|
|
|