##############################################################################
# Copyright (c) Members of the EGEE Collaboration. 2008.
# 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_gip_hydra
#
# DESCRIPTION : This function configures the GIP for Hydra
#
# AUTHORS :     Akos.Frohner@cern.ch
#
# YAIM MODULE:  glite-yaim-hydra
#
##############################################################################

function config_gip_hydra_check() {
 requires $1 SITE_INFO
 return 0
}

function config_gip_hydra() {

    yaimlog INFO "Installing the BDII info provider script"
    ABS_SITE_INFO="${SITE_INFO}"
    if [ "${SITE_INFO:0:1}" != "/" ]; then
      ABS_SITE_INFO="${PWD}/${SITE_INFO}"
    fi
    cat << EOF  > ${INSTALL_ROOT}/glite/etc/gip/provider/glite-hydra-provider
#! /bin/sh
${INSTALL_ROOT}/glite/etc/glite-data-hydra-service/info-provider --values ${ABS_SITE_INFO}
EOF

    chmod +x ${INSTALL_ROOT}/glite/etc/gip/provider/glite-hydra-provider

    GIP_FRESHNESS=600
    GIP_CACHE_TTL=1200
    GIP_TIMEOUT=300

    yaimlog INFO "Generating a local services.xml file"
    ${INSTALL_ROOT}/glite/etc/glite-data-hydra-service/info-provider --values ${SITE_INFO} --file >${INSTALL_ROOT}/glite/etc/services.xml

    return 0
}

