#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2000,2007 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#
# @(#)13   1.4         src/rsct/cfg_access/scaffold/ct_refresh_node.sh, cfg.access, rsct_relgh, relghs001a 1/16/01 15:25:12
#
# Temporary command file to enable RSCT HA subsystems 
# with the manually edited 'subsys.conf' and 'topology.conf'
#
# Usage: ct_refresh_node topology.conf [subsys.conf]
#

PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin
RSCTBIN=/usr/sbin/rsct/bin
CTROOT=/var/ct

#
basecmd=$(basename $0)
#
function usage
{
    cmdline="${basecmd} topology.conf [subsys.conf]"
    print -u2 "Usage: $cmdline"
}


#
#

if [[ -z $1 ]]; then
    usage
    exit 1;
fi

TOPOLOGYCONF=$1
SUBSYSCONF=$2
CLSTNAME=$(${RSCTBIN}/ct_clusterinfo -c)
if [[ -z $CLSTNAME ]]; then
    print -u2 "Cluster name not found"
    usage
    exit 1;
fi

if [[ ! -a $TOPOLOGYCONF ]]; then
    print -u "File $TOPOLOGYCONF not found"
    usage
    exit 1;
fi

CLSTDIR=/var/ct/${CLSTNAME}
if [[ ! -d ${CLSTDIR}/cfg ]]; then
   mkdir -p ${CLSTDIR}/cfg
fi

# copy SUBSYSCONF to /var/ct/<CLSTNAME>/cfg/subsys.conf
if [[ -a $SUBSYSCONF ]]; then
   cp -f $SUBSYSCONF ${CLSTDIR}/cfg/subsys.conf
fi

# also copy topology.conf to /var/ct/<CLSTNAME>/cfg/topology.conf
cp -f $TOPOLOGYCONF ${CLSTDIR}/cfg/topology.conf

exec $RSCTBIN/cthactrl -r

exit 1
