##############################################################################
# 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_glite_init
#
# DESCRIPTION : This function calls the python configuration script.
#
# AUTHORS :     Robert.Harakaly@cern.ch
#
# NOTES : 
#
# YAIM MODULE:  glite-yaim-clients
#                 
##############################################################################

function config_glite_init(){
	INSTALL_ROOT=${INSTALL_ROOT:-/usr}
	#	if glite_init set do not run converter (already done)
	export NODE_TYPE_LIST FUNCTIONS_DIR
	#export GLITE_LOCATION=$INSTALL_ROOT/glite
#    export PATH=$INSTALL_ROOT/glite/bin:$INSTALL_ROOT/lcg/bin:$PATH
#    export LD_LIBRARY_PATH=$INSTALL_ROOT/lcg/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=/opt/lcg/lib:$LD_LIBRARY_PATH
	python ${FUNCTIONS_DIR}/../libexec/YAIM2gLiteConvertor.py
	if [ $? != 0 ]; then
		echo "gLite configuration script has returned nonzero return code"
		return 1
	fi
	GLITE_SCRIPTS_DIR=/opt/glite/etc/config/scripts
	glite_init=true
	return 0
}
function run_glite_command(){
	${GLITE_SCRIPTS_DIR}/$1 $2
	if [ $? != 0 ]; then
		echo "gLite configuration script has returned nonzero return code"
		return 1
	fi
	return 0
}
function config_ssh(){
		cat <<EOF > /etc/ssh/ssh_config
Host *
Protocol 2,1
   RhostsAuthentication yes
   RhostsRSAAuthentication yes
   RSAAuthentication yes
   PasswordAuthentication yes
   EnableSSHKeysign yes
   HostbasedAuthentication yes

EOF
return 0
}

