
#!/bin/sh

# Copyright (c) Members of the EGEE Collaboration. 2004 
# See http://eu-egee.org/partners/ for details on the copyright holders
# For license conditions see the license file or http://eu-egee.org/license.html

# glite-wms_installer v. 1.0.7
#
# The glite-wms_installer installs the gLite Workload Management System
#
# Usage: glite-wms_installer [-u|-v|--help]
#        -u          uninstall
#        -v          print version
#        --help      print script usage info
# Return codes: 0 - Ok
#               1 - if a file could not be downloaded

###############################################################################

#Parse the RPMLIST to strip out the RPMS that are already installed
function parseRPMList()
{
        newRPMLIST=""
        localRPMLIST=`rpm -qa`
        for i in $RPMLIST
        do
                g=`echo $i | sed -e 's/\.i386\.rpm//g'`
                g=`echo $g | sed -e 's/\.noarch\.rpm//g'`
                if [ -z "`echo $localRPMLIST | grep $g`" ]; then
                        newRPMLIST="${newRPMLIST} $i"
                else
                        echo "$i is already installed. It will be skipped."
                fi
        done
                                                                                                                                                             
        RPMLIST=$newRPMLIST
}

#Parse the SCRIPTLIST to execute all scripts
function parseScriptList()
{
        for i in $SCRIPTLIST
        do
        		if [ "$INSTALL" = "true" ]; then
	                $i
	            else
	            	$i -u
	            fi
        done
}

#Downloads and install the module RPMS
function install()
{

	INSTALL=true

	version
	echo
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo x Please wait, downloading the gLite Workload Management System... x
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo

    mkdir -p glite-wms
    cd glite-wms

	# Download global dependencies	
	
 	

	# Download glite-wms-service scripts from repository
		

	# Download glite-wms-service dependencies RPMS from repository
		
							
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/glite-essentials-cpp-1.1.1-1_EGEE.i386.rpm
if [ ! -f "glite-essentials-cpp-1.1.1-1_EGEE.i386.rpm" ]
then
	echo 
	echo ERROR: glite-essentials-cpp-1.1.1-1_EGEE.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-essentials-cpp-1.1.1-1_EGEE.i386.rpm"
			
						  
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/vdt_globus_essentials-VDT1.2.2rh9-1.i386.rpm
if [ ! -f "vdt_globus_essentials-VDT1.2.2rh9-1.i386.rpm" ]
then
	echo 
	echo ERROR: vdt_globus_essentials-VDT1.2.2rh9-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST vdt_globus_essentials-VDT1.2.2rh9-1.i386.rpm"
			

                
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/vdt_globus_info_essentials-VDT1.2.2rh9-1.i386.rpm
if [ ! -f "vdt_globus_info_essentials-VDT1.2.2rh9-1.i386.rpm" ]
then
	echo 
	echo ERROR: vdt_globus_info_essentials-VDT1.2.2rh9-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST vdt_globus_info_essentials-VDT1.2.2rh9-1.i386.rpm"
			
						
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/gpt-VDT1.2.2rh9-1.i386.rpm
if [ ! -f "gpt-VDT1.2.2rh9-1.i386.rpm" ]
then
	echo 
	echo ERROR: gpt-VDT1.2.2rh9-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST gpt-VDT1.2.2rh9-1.i386.rpm"
									 
												  
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/vdt_globus_sdk-VDT1.2.2rh9-1.i386.rpm
if [ ! -f "vdt_globus_sdk-VDT1.2.2rh9-1.i386.rpm" ]
then
	echo 
	echo ERROR: vdt_globus_sdk-VDT1.2.2rh9-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST vdt_globus_sdk-VDT1.2.2rh9-1.i386.rpm"
			

                
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/edg-replica-manager-client-cpp_gcc3_2_2-norgma_suite-2.3.1-1_sl3_EGEE.i386.rpm
if [ ! -f "edg-replica-manager-client-cpp_gcc3_2_2-norgma_suite-2.3.1-1_sl3_EGEE.i386.rpm" ]
then
	echo 
	echo ERROR: edg-replica-manager-client-cpp_gcc3_2_2-norgma_suite-2.3.1-1_sl3_EGEE.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST edg-replica-manager-client-cpp_gcc3_2_2-norgma_suite-2.3.1-1_sl3_EGEE.i386.rpm"
			

	 			
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/condor-6.7.6-1.i386.rpm
if [ ! -f "condor-6.7.6-1.i386.rpm" ]
then
	echo 
	echo ERROR: condor-6.7.6-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST condor-6.7.6-1.i386.rpm"
				
					  
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/condorc-exec-6.7.3-1_EGEE.i386.rpm
if [ ! -f "condorc-exec-6.7.3-1_EGEE.i386.rpm" ]
then
	echo 
	echo ERROR: condorc-exec-6.7.3-1_EGEE.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST condorc-exec-6.7.3-1_EGEE.i386.rpm"
			

	  			
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/ares-1.1.1-EGEE.i386.rpm
if [ ! -f "ares-1.1.1-EGEE.i386.rpm" ]
then
	echo 
	echo ERROR: ares-1.1.1-EGEE.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST ares-1.1.1-EGEE.i386.rpm"
							  
					  			
	  			
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-client-4.0.20-0.i386.rpm
if [ ! -f "MySQL-client-4.0.20-0.i386.rpm" ]
then
	echo 
	echo ERROR: MySQL-client-4.0.20-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST MySQL-client-4.0.20-0.i386.rpm"
							  
					  	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/myproxy-1.14-EGEE.i386.rpm
if [ ! -f "myproxy-1.14-EGEE.i386.rpm" ]
then
	echo 
	echo ERROR: myproxy-1.14-EGEE.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST myproxy-1.14-EGEE.i386.rpm"
			
					  			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Expect.pm-1.01-9.i386.rpm
if [ ! -f "perl-Expect.pm-1.01-9.i386.rpm" ]
then
	echo 
	echo ERROR: perl-Expect.pm-1.01-9.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Expect.pm-1.01-9.i386.rpm"
			
						
			

	# Download glite-wms-service RPMS from repository
		
			    
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/noarch/RPMS/glite-config-1.1.1-3.noarch.rpm
if [ ! -f "glite-config-1.1.1-3.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-config-1.1.1-3.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-config-1.1.1-3.noarch.rpm"
			
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/noarch/RPMS/glite-wms-config-1.0.7-2.noarch.rpm
if [ ! -f "glite-wms-config-1.0.7-2.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-wms-config-1.0.7-2.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-config-1.0.7-2.noarch.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-utils-exception-1.0.1-1.i386.rpm
if [ ! -f "glite-wms-utils-exception-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-utils-exception-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-utils-exception-1.0.1-1.i386.rpm"
			
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-utils-jobid-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-utils-jobid-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-utils-jobid-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-utils-jobid-1.0.0-1.i386.rpm"
				
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-utils-tls-1.0.1-1.i386.rpm
if [ ! -f "glite-wms-utils-tls-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-utils-tls-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-utils-tls-1.0.1-1.i386.rpm"
			
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-common-1.0.2-1.i386.rpm
if [ ! -f "glite-wms-common-1.0.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-common-1.0.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-common-1.0.2-1.i386.rpm"
			
					   
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-jdl-1.1.2-2.i386.rpm
if [ ! -f "glite-wms-jdl-1.1.2-2.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-jdl-1.1.2-2.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-jdl-1.1.2-2.i386.rpm"
			
					   
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-purger-1.0.2-2.i386.rpm
if [ ! -f "glite-wms-purger-1.0.2-2.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-purger-1.0.2-2.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-purger-1.0.2-2.i386.rpm"
			
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-jobsubmission-1.0.1-2.i386.rpm
if [ ! -f "glite-wms-jobsubmission-1.0.1-2.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-jobsubmission-1.0.1-2.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-jobsubmission-1.0.1-2.i386.rpm"
					
					   
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-thirdparty-globus_gridftp_server-1.5.2-1.i386.rpm
if [ ! -f "glite-wms-thirdparty-globus_gridftp_server-1.5.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-thirdparty-globus_gridftp_server-1.5.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-thirdparty-globus_gridftp_server-1.5.2-1.i386.rpm"
					
				 
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-1.0.5-1.i386.rpm
if [ ! -f "glite-wms-manager-1.0.5-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-1.0.5-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-1.0.5-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-ns-daemon-1.0.5-2.i386.rpm
if [ ! -f "glite-wms-manager-ns-daemon-1.0.5-2.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-ns-daemon-1.0.5-2.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-ns-daemon-1.0.5-2.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-configuration-1.0.2-1.i386.rpm
if [ ! -f "glite-wms-configuration-1.0.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-configuration-1.0.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-configuration-1.0.2-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-ns-commands-1.0.2-1.i386.rpm
if [ ! -f "glite-wms-manager-ns-commands-1.0.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-ns-commands-1.0.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-ns-commands-1.0.2-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-helper-1.0.5-1.i386.rpm
if [ ! -f "glite-wms-helper-1.0.5-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-helper-1.0.5-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-helper-1.0.5-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-classad_plugin-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-classad_plugin-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-classad_plugin-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-classad_plugin-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-ism-1.0.7-1.i386.rpm
if [ ! -f "glite-wms-ism-1.0.7-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-ism-1.0.7-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-ism-1.0.7-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-broker-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-broker-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-broker-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-broker-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-rls-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-rls-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-rls-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-rls-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-ns-common-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-manager-ns-common-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-ns-common-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-ns-common-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-ns-fsm-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-manager-ns-fsm-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-ns-fsm-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-ns-fsm-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-manager-ns-versions-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-manager-ns-versions-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-manager-ns-versions-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-manager-ns-versions-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-brokerinfo-1.1.4-1.i386.rpm
if [ ! -f "glite-wms-brokerinfo-1.1.4-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-brokerinfo-1.1.4-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-brokerinfo-1.1.4-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-brokerinfo-access-1.0.1-1.i386.rpm
if [ ! -f "glite-wms-brokerinfo-access-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-brokerinfo-access-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-brokerinfo-access-1.0.1-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-interactive-1.0.0-1.i386.rpm
if [ ! -f "glite-wms-interactive-1.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-interactive-1.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-interactive-1.0.0-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-thirdparty-bypass-2.5.3-9.i386.rpm
if [ ! -f "glite-wms-thirdparty-bypass-2.5.3-9.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-thirdparty-bypass-2.5.3-9.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-thirdparty-bypass-2.5.3-9.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-security-proxyrenewal-1.0.13-1.i386.rpm
if [ ! -f "glite-security-proxyrenewal-1.0.13-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-proxyrenewal-1.0.13-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-proxyrenewal-1.0.13-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-security-voms-1.2.32-1.i386.rpm
if [ ! -f "glite-security-voms-1.2.32-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-1.2.32-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-1.2.32-1.i386.rpm"
			
					
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-wms-matchmaking-1.0.2-1.i386.rpm
if [ ! -f "glite-wms-matchmaking-1.0.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-wms-matchmaking-1.0.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-wms-matchmaking-1.0.2-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-ce-monitor-client-api-c-1.0.2-1.i386.rpm
if [ ! -f "glite-ce-monitor-client-api-c-1.0.2-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-ce-monitor-client-api-c-1.0.2-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-ce-monitor-client-api-c-1.0.2-1.i386.rpm"
			

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-ce-wsdl-1.0.1-1.i386.rpm
if [ ! -f "glite-ce-wsdl-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-ce-wsdl-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-ce-wsdl-1.0.1-1.i386.rpm"
			
					
			

	# Download  scripts from repository
		

	# Download  dependencies RPMS from repository
		

	# Download  RPMS from repository
		
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-lb-client-interface-1.0.3-1.i386.rpm
if [ ! -f "glite-lb-client-interface-1.0.3-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-lb-client-interface-1.0.3-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-lb-client-interface-1.0.3-1.i386.rpm"
			
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-lb-client-1.0.1-1.i386.rpm
if [ ! -f "glite-lb-client-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-lb-client-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-lb-client-1.0.1-1.i386.rpm"
			
	
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-lb-common-1.1.4-1.i386.rpm
if [ ! -f "glite-lb-common-1.1.4-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-lb-common-1.1.4-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-lb-common-1.1.4-1.i386.rpm"
			
	
	            
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/bin/rhel30/i386/RPMS/glite-lb-logger-1.0.1-1.i386.rpm
if [ ! -f "glite-lb-logger-1.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-lb-logger-1.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-lb-logger-1.0.1-1.i386.rpm"
			
                    
			

	# Download glite-security-utils-service scripts from repository
		
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/installers/glite-security-utils_installer.sh
if [ ! -f "glite-security-utils_installer.sh" ]
then
	echo 
	echo ERROR: glite-security-utils_installer.sh could not be downloaded!
	exit 1
fi
chmod u+x glite-security-utils_installer.sh
SCRIPTLIST="$SCRIPTLIST ./glite-security-utils_installer.sh"
			

	# Download glite-security-utils-service dependencies RPMS from repository
		

	# Download glite-security-utils-service RPMS from repository
		

	# Download glite-rgma-servicetool scripts from repository
		
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/installers/glite-rgma-servicetool_installer.sh
if [ ! -f "glite-rgma-servicetool_installer.sh" ]
then
	echo 
	echo ERROR: glite-rgma-servicetool_installer.sh could not be downloaded!
	exit 1
fi
chmod u+x glite-rgma-servicetool_installer.sh
SCRIPTLIST="$SCRIPTLIST ./glite-rgma-servicetool_installer.sh"
			

	# Download glite-rgma-servicetool dependencies RPMS from repository
		

	# Download glite-rgma-servicetool RPMS from repository
		
		
	# Download and install subservices

	parseScriptList

	# Install all RPMS

	echo
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo x Please wait, installing the gLite Workload Management System... x
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo
	parseRPMList
	if [ ! -z "$RPMLIST" ]; then
		rpm -Uvh $RPMLIST
		rpm_return=$?
	else
		echo All required RPMS are already installed
		rpm_return=0
	fi
	if [ "$rpm_return" == "0" ]; then
		echo
		echo Done!
		echo
		echo Before using the gLite Workload Management System:
		echo
		echo "(1) Install Java"
		echo
		echo "    Due to license restrictions we cannot redistribute Java."
		echo "    If you have not installed Java, please install Java 1.4.2."
		echo "    You can download it from http://java.sun.com/."
		echo
		echo "(2) Customize the glite-mkgridmap.conf file"
		echo
		echo "    Insert in the glite-mkgridmap.conf file the VOMS groups"
		echo "    you want to get mappings for. These entries will be used to"
		echo "    get the user DN mappings to the configured pool accounts"
		echo
		echo "(3) Create configuration"
		echo
		echo "    a) Centralized configuration:"
		echo "       Create or update the global gLite configuration file"
		echo "           /opt/glite/etc/config/glite-global.cfg.xml"
		echo "       Create or updated the Site Configuration file"
		echo "       with the values for this WMS node and publish it"
		echo "       A template for site configuration of a typical"
		echo "       gLite WMS node is provided in"
		echo "           /opt/glite/etc/config/templates/glite-wms-site-config.xml"
		echo
		echo "    b) Local configuration:"
		echo "       Create or update the WMS configuration file"
		echo "           /opt/glite/etc/config/glite-wms.cfg.xml ,"		
		echo "       the R-GMA common configuration file"
		echo "           /opt/glite/etc/config/glite-rgma-common.cfg.xml ,"
		echo "       the RGMA servicetool configuration file"
		echo "           /opt/glite/etc/config/glite-rgma-servicetool.cfg.xml"
		echo "       the gLite Security Utilities configuration file"
		echo "           /opt/glite/etc/config/glite-security-utils.cfg.xml"
		echo "       and the general glite configuration file"
		echo "           /opt/glite/etc/config/glite-global.cfg.xml"
		echo
		echo "       Configuration file templates are provided in"
		echo "           /opt/glite/etc/config/templates/."
		echo "       Copy these templates if they do not exist yet to /opt/glite/etc/config/"
		echo "       and set the configuration values accordingly."
		echo "       Make sure that all parameters 'changeme' are properly set in the files."
		echo
		echo "(4) Configure and start the Workload Management system"
		echo
		echo "    Run the configuration script /opt/glite/etc/config/scripts/glite-wms-config.py"
		echo "    The script will completely configure and start the Workload Management System"
		echo "    as well as the R-GMA servicetool."
		echo
	else
		echo
		echo An error occurred while installing the WMS RPMS.
		echo Most likely one or more of the RPMS to be installed require
		echo additional dependencies or are older than already installed packages.
		echo Please refer to the rpm error message above for more details.
	fi
	echo
	echo For more information refer to the gLite Installation and User Guides
	echo or to the gLite web site \(http:\/\/www.glite.org\)
	echo Please report problems and comments to the gLite Team at
	echo project-eu-egee-glite-bugs@cern.ch

	cd ..
}

###############################################################################
function uninstall()
{
	version

	# Global dependencies	
	
 	

	# Download glite-wms-service scripts from repository
		

	# glite-wms-service dependencies RPMS from repository
		
							
				
RPMLIST="$RPMLIST glite-essentials-cpp-1.1.1-1_EGEE"
					 
						  
				
RPMLIST="$RPMLIST vdt_globus_essentials-VDT1.2.2rh9-1"
					 

                
RPMLIST="$RPMLIST vdt_globus_info_essentials-VDT1.2.2rh9-1"
					 
						
				
RPMLIST="$RPMLIST gpt-VDT1.2.2rh9-1"
					 						 
												  
				
RPMLIST="$RPMLIST vdt_globus_sdk-VDT1.2.2rh9-1"
					 

                
RPMLIST="$RPMLIST edg-replica-manager-client-cpp_gcc3_2_2-norgma_suite-2.3.1-1_sl3_EGEE"
					 

	 			
RPMLIST="$RPMLIST condor-6.7.6-1"
					 	
					  
				
RPMLIST="$RPMLIST condorc-exec-6.7.3-1_EGEE"
					 

	  			
RPMLIST="$RPMLIST ares-1.1.1-EGEE"
					 				  
					  			
	  			
RPMLIST="$RPMLIST MySQL-client-4.0.20-0"
					 				  
					  	
				
RPMLIST="$RPMLIST myproxy-1.14-EGEE"
					 
					  			
				
RPMLIST="$RPMLIST perl-Expect.pm-1.01-9"
					 
						
			

	# glite-wms-service RPMS from repository
		
			    
RPMLIST="$RPMLIST glite-config-1.1.1-3"
                                         
			
				
RPMLIST="$RPMLIST glite-wms-config-1.0.7-2"
                                         

				
RPMLIST="$RPMLIST glite-wms-utils-exception-1.0.1-1"
                                         
	
				
RPMLIST="$RPMLIST glite-wms-utils-jobid-1.0.0-1"
                                         	
	
				
RPMLIST="$RPMLIST glite-wms-utils-tls-1.0.1-1"
                                         
	
				
RPMLIST="$RPMLIST glite-wms-common-1.0.2-1"
                                         
					   
				
RPMLIST="$RPMLIST glite-wms-jdl-1.1.2-2"
                                         
					   
				
RPMLIST="$RPMLIST glite-wms-purger-1.0.2-2"
                                         
	
				
RPMLIST="$RPMLIST glite-wms-jobsubmission-1.0.1-2"
                                         		
					   
				
RPMLIST="$RPMLIST glite-wms-thirdparty-globus_gridftp_server-1.5.2-1"
                                         		
				 
				
RPMLIST="$RPMLIST glite-wms-manager-1.0.5-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-manager-ns-daemon-1.0.5-2"
                                         

				
RPMLIST="$RPMLIST glite-wms-configuration-1.0.2-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-manager-ns-commands-1.0.2-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-helper-1.0.5-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-classad_plugin-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-ism-1.0.7-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-broker-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-rls-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-manager-ns-common-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-manager-ns-fsm-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-manager-ns-versions-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-brokerinfo-1.1.4-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-brokerinfo-access-1.0.1-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-interactive-1.0.0-1"
                                         

				
RPMLIST="$RPMLIST glite-wms-thirdparty-bypass-2.5.3-9"
                                         

				
RPMLIST="$RPMLIST glite-security-proxyrenewal-1.0.13-1"
                                         

				
RPMLIST="$RPMLIST glite-security-voms-1.2.32-1"
                                         
					
				
RPMLIST="$RPMLIST glite-wms-matchmaking-1.0.2-1"
                                         

				
RPMLIST="$RPMLIST glite-ce-monitor-client-api-c-1.0.2-1"
                                         

				
RPMLIST="$RPMLIST glite-ce-wsdl-1.0.1-1"
                                         
					
			

	# Download  scripts from repository
		

	#  dependencies RPMS from repository
		

	#  RPMS from repository
		
			
				
RPMLIST="$RPMLIST glite-lb-client-interface-1.0.3-1"
                                         
	
				
RPMLIST="$RPMLIST glite-lb-client-1.0.1-1"
                                         
	
				
RPMLIST="$RPMLIST glite-lb-common-1.1.4-1"
                                         
	
	            
RPMLIST="$RPMLIST glite-lb-logger-1.0.1-1"
                                         
                    
			

	# Download glite-security-utils-service scripts from repository
		
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/installers/glite-security-utils_installer.sh
if [ ! -f "glite-security-utils_installer.sh" ]
then
	echo 
	echo ERROR: glite-security-utils_installer.sh could not be downloaded!
	exit 1
fi
chmod u+x glite-security-utils_installer.sh
SCRIPTLIST="$SCRIPTLIST ./glite-security-utils_installer.sh"
			

	# glite-security-utils-service dependencies RPMS from repository
		

	# glite-security-utils-service RPMS from repository
		

	# Download glite-rgma-servicetool scripts from repository
		
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.1/R20050430/installers/glite-rgma-servicetool_installer.sh
if [ ! -f "glite-rgma-servicetool_installer.sh" ]
then
	echo 
	echo ERROR: glite-rgma-servicetool_installer.sh could not be downloaded!
	exit 1
fi
chmod u+x glite-rgma-servicetool_installer.sh
SCRIPTLIST="$SCRIPTLIST ./glite-rgma-servicetool_installer.sh"
			

	# glite-rgma-servicetool dependencies RPMS from repository
		

	# glite-rgma-servicetool RPMS from repository
		
		
	# Uninstall all RPMS
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo x  Please wait, uninstalling the gLite Workload Management System...   x
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaxxxxxxxx
	echo
	rpm -ev $RPMLIST
	if [ "$?" == "0" ]; then
		echo
		echo Done!
	else
		echo
		echo An error occurred while removing the WMS RPMS.
		echo Most likely one or more of the RPMS to be removed have
		echo dependent packages.
		echo Please refer to the rpm error message above for more details.
	fi
}

###############################################################################
function usage()
{
	echo 
	echo Copyright \(c\) Members of the EGEE Collaboration. 2004 
	echo See http://eu-egee.org/partners/ for details on the copyright holders
	echo For license conditions see the license file or http://eu-egee.org/license.html
	echo 
	echo glite-wms_installer v. 1.0.7
	echo 
	echo The glite-wms_installer installs the gLite Workload Management System
	echo 
	echo Usage: glite-wms_installer \[-u\|-v\|--help\]
	echo -u          uninstall
	echo -v          print version
	echo --help      print script usage info
	echo 
	echo Return codes:
	echo 0 - Ok
	echo 1 - if a file could not be downloaded
	echo 
}

###############################################################################
function version
{
	echo 
	echo Copyright \(c\) Members of the EGEE Collaboration. 2004 
	echo See http://eu-egee.org/partners/ for details on the copyright holders
	echo For license conditions see the license file or http://eu-egee.org/license.html
	echo 
	echo glite-wms_installer v. 1.0.7
	echo 
}


RPMLIST=

###############################################################################
# Main

while getopts uvh opt
do
	case $opt in
		'u') uninstall
		     exit 0	
		     ;;
		'v') version
		     exit 0	
		     ;;
		'h') usage
		     exit 0	
		     ;;
	esac
done

install

exit 0
	
