##############################################################################
# Copyright (c) Members of the EGEE Collaboration. 2004. 
# See http://www.eu-egee.org/partners/ for details on the copyright 
# holders.  
#
# Licensed 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.
##############################################################################
#
# NAME :        config_ui_tar
#
# DESCRIPTION : This function configures a 3.1 TAR UI.
#
# AUTHORS :     Andreas.Unterkircher@cern.ch
#
# NOTES :       
#
# YAIM MODULE:  glite-yaim-clients
#                 
##############################################################################

function config_ui_tar_check (){

  requires $1 GLITE_EXTERNAL_ROOT
  return $?

}

function config_ui_tar_setenv(){

  if [ -d ${GLITE_EXTERNAL_ROOT}/usr/lib/perl5/vendor_perl/5.8.5 ]; then
    yaimgridpath_append PERL5LIB ${GLITE_EXTERNAL_ROOT}/usr/lib/perl5/vendor_perl/5.8.5
  fi

  if [ -d ${GLITE_EXTERNAL_ROOT}/usr/lib/perl5/vendor_perl/5.8.8 ]; then
    yaimgridpath_append PERL5LIB ${GLITE_EXTERNAL_ROOT}/usr/lib/perl5/vendor_perl/5.8.8
  fi

  yaimgridpath_append LD_LIBRARY_PATH ${GLITE_EXTERNAL_ROOT}/usr/lib

  if [ "x${OS_ARCH}" = "x64BIT" ]; then
    if [ -d ${GLITE_EXTERNAL_ROOT}/usr/lib64 ]; then
        yaimgridpath_append LD_LIBRARY_PATH ${GLITE_EXTERNAL_ROOT}/usr/lib64
    fi
  fi

  if central_certs ; then
    yaimgridenv_set X509_CERT_DIR ${X509_CERT_DIR:-/etc/grid-security/certificates}
  else
    yaimgridenv_set X509_CERT_DIR ${X509_CERT_DIR:-${GLITE_EXTERNAL_ROOT}/etc/grid-security/certificates}
  fi

  yaimgridenv_set X509_VOMS_DIR ${X509_VOMS_DIR:-${GLITE_EXTERNAL_ROOT}/etc/grid-security/vomsdir}
}

function config_ui_tar(){
	if [ -d ${INSTALL_ROOT}/globus/lib ]; then
         sed -i "s:/opt/globus/lib:${INSTALL_ROOT}/globus/lib:g" ${INSTALL_ROOT}/globus/lib/*.la 
         if [ $? -ne 0 ]; then
	  yaimlog ERROR "Error while executing sed -i \"s:/opt/globus/lib:${INSTALL_ROOT}/globus/lib:g\" ${INSTALL_ROOT}/globus/lib/*.la"
          return 1
         fi
        fi
	return 0
}
