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

config_rfio() {

if [ "x${OS_TYPE}" != "xdebian" ]; then

INSTALL_ROOT=${INSTALL_ROOT:-/usr}

####@ This function turns rfio on where necessary and
####@ just as important, turns it off where it isn't necessary

if ( echo "${NODE_TYPE_LIST}" | grep -q SE_classic ); then

    if [ "x`grep rfio /etc/services | grep tcp`" = "x"  ]; then
	echo "rfio     5001/tcp" >> /etc/services
    fi

    if [ "x`grep rfio /etc/services | grep udp`" = "x"  ]; then
	echo "rfio     5001/udp" >> /etc/services
    fi
    
    /sbin/service rfiod restart
    /sbin/chkconfig --level 2345 rfiod on

elif ( echo "${NODE_TYPE_LIST}" | grep -q SE_dpm ); then

    return 0
elif (  rpm -qa | grep -q CASTOR-client ); then 

    if [ -f /etc/init.d/rfiod ]; then 
      yaimlog DEBUG "Stopping rfio service."
       /sbin/service rfiod stop
       /sbin/chkconfig --level 2345 rfiod off
    else
      yaimlog DEBUG "No rfio service has been found, so not stopping it."
    fi
fi

return 0

else
  yaimlog INFO "config_rfio is not executed in Debian platforms"
fi

}
