#!/bin/bash
#
# File       : set_platform
# description: Script to setup the platform
#
# Copyright (C) 2004 Networks Associates Technology Inc. All rights reserved.
#

if [ -f $NETAWSS/.profile.vars ]; then 
    . $NETAWSS/.profile.vars 
else 
    . /var/NAIENV/.profile.vars 
fi 
shopt -s extglob
if [ -f /.ws_product_name ]
then
    . /.ws_product_name
fi
if [[ -n ${WS_PRODUCT_NAME} ]]
then
    fgrep -rl PRODUCT_NAME_STRING \
	    ${NETAWSS}/ui/*.properties \
	    ${NETAWSS}/ui/*.html \
	    ${NETAWSS}/ui/html \
	    ${NETAWSS}/ui/xml \
	    ${NETAWSS}/ui/xsl \
	    ${NETAWSS}/ui/jscript \
	    ${NETAWSS}/proto/xmlconfdir/*.xml |
	xargs -t perl -pi -e "s/PRODUCT_NAME_STRING/${WS_PRODUCT_NAME}/g"
fi

# Now set up the platform information
PROTODIR=${NETAWSS}/proto/xmlconfdir
PLATFORM=${PROTODIR}/${WS_PRODUCT_NAME}.cnf
test -f ${PLATFORM}
if [ $? = 0 ]
then
    for f in ${PROTODIR}/*.xml
    do
	mv ${f} ${f}.old
	${WSMGMT}/xml-replace ${PLATFORM} ${f}.old ${f}
	rm -f ${f}.old
    done
fi

exit 0
