##############################################################################
# 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_sysconfig_globus
#
# DESCRIPTION : This function configures the globus sysconfig.
#
# AUTHORS :     Robert.Harakaly@cern.ch
#
# NOTES :
#
# YAIM MODULE:  glite-yaim-core
#
##############################################################################

config_sysconfig_globus() {

INSTALL_ROOT=${INSTALL_ROOT:-/opt}
mkdir -p ${GLITE_EXTERNAL_ROOT:-}/etc/sysconfig/


####@ Writes /etc/sysconfig/globus
cat <<EOF > ${GLITE_EXTERNAL_ROOT:-}/etc/sysconfig/globus
GLOBUS_CONFIG=${GLITE_EXTERNAL_ROOT:-}/etc/globus.conf
export LANG=C
export GATEKEEPER_DGAS_DIR=$INSTALL_ROOT/edg/var/gatekeeper
EOF

# Set GLOBUS_TCP_PORT_RANGE, but not for nodes which are only WNs
if [ "$GLOBUS_TCP_PORT_RANGE" ] && ( ! echo $NODE_TYPE_LIST | egrep -q '^ *WN_?[[:alpha:]]* *$' ); then
    echo "GLOBUS_TCP_PORT_RANGE=\"$GLOBUS_TCP_PORT_RANGE\"" >> ${GLITE_EXTERNAL_ROOT:-}/etc/sysconfig/globus
fi

# not needed for EMI
####@ Touches $INSTALL_ROOT/globus/libexec/globus-script-initializer and sets it's proper permission

#(
#    # HACK to avoid complaints from services that do not need it,
#    # but get started via a login shell before the file is created...

#    f=$INSTALL_ROOT/globus/libexec/globus-script-initializer
#    echo '' > $f
#    chmod 755 $f
#)

return 0
}
