#!/bin/sh
# Copyright(c) Sybase, Inc.

#       We are in multi node so SYBASE_UA points to the top level
#       check and make sure a node specific sub directory
#       has been created
#
if [ ! -d ${SYBASE_UA}/nodes ]; then
  mkdir ${SYBASE_UA}/nodes
fi

if [ ! -d ${SYBASE_UA}/nodes/$nodename ]; then
  echo Creating a UAF nodes subdirectory representing the node $nodename
  mkdir ${SYBASE_UA}/nodes/$nodename
  ln -s ${SYBASE_UA}/nodes/$nodename ${SYBASE_UA}/nodes/$nodename.$DOMAINNAME
  for f in conf plugins services
    do
      cp -R ${SYBASE_UA}/$f ${SYBASE_UA}/nodes/$nodename/$f
    done
  for f in common rtlib server shared templates utility
    do
      ln -s ${SYBASE_UA}/$f ${SYBASE_UA}/nodes/$nodename/$f
    done
fi

#
#       repoint the SYBASE_UA to the node specific sub directory
#
SYBASE_UA=${SYBASE_UA}/nodes/$nodename

export SYBASE_UA

echo Agent Home: $SYBASE_UA

