
#!/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-voms-server-mysql_installer v. 2.2.5
#
# The glite-voms-server-mysql_installer installs the gLite VOMS server (MySQL version)
#
# Usage: glite-voms-server-mysql_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 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo "x Please wait, downloading the VOMS server (MySQL) ...                 x"
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo

        mkdir -p glite-voms-server-mysql
        cd glite-voms-server-mysql

	# Download global dependencies	
	
	
	# Download glite-voms-service scripts from repository
	

	# Download glite-voms-service dependencies RPMS from repository
		
				
wget -N -nv 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 -nv 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 -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/tomcat5-5.0.28-11_EGEE.noarch.rpm
if [ ! -f "tomcat5-5.0.28-11_EGEE.noarch.rpm" ]
then
	echo 
	echo ERROR: tomcat5-5.0.28-11_EGEE.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST tomcat5-5.0.28-11_EGEE.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Crypt-SSLeay-0.51-4.i386.rpm
if [ ! -f "perl-Crypt-SSLeay-0.51-4.i386.rpm" ]
then
	echo 
	echo ERROR: perl-Crypt-SSLeay-0.51-4.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Crypt-SSLeay-0.51-4.i386.rpm"
			 	
						
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Authen-SASL-2.08-1.1.el3.rf.noarch.rpm
if [ ! -f "perl-Authen-SASL-2.08-1.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-Authen-SASL-2.08-1.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Authen-SASL-2.08-1.1.el3.rf.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Digest-HMAC-1.01-11.1.noarch.rpm
if [ ! -f "perl-Digest-HMAC-1.01-11.1.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-Digest-HMAC-1.01-11.1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Digest-HMAC-1.01-11.1.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Digest-SHA1-2.01-15.1.i386.rpm
if [ ! -f "perl-Digest-SHA1-2.01-15.1.i386.rpm" ]
then
	echo 
	echo ERROR: perl-Digest-SHA1-2.01-15.1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Digest-SHA1-2.01-15.1.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-MIME-Lite-2.117-2.1.el3.rf.noarch.rpm
if [ ! -f "perl-MIME-Lite-2.117-2.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-MIME-Lite-2.117-2.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-MIME-Lite-2.117-2.1.el3.rf.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Net-Jabber-2.0-1.1.el3.rf.noarch.rpm
if [ ! -f "perl-Net-Jabber-2.0-1.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-Net-Jabber-2.0-1.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Net-Jabber-2.0-1.1.el3.rf.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-Net-XMPP-1.0-1.1.el3.rf.noarch.rpm
if [ ! -f "perl-Net-XMPP-1.0-1.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-Net-XMPP-1.0-1.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-Net-XMPP-1.0-1.1.el3.rf.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-SOAP-Lite-0.60a-1.1.el3.rf.noarch.rpm
if [ ! -f "perl-SOAP-Lite-0.60a-1.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-SOAP-Lite-0.60a-1.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-SOAP-Lite-0.60a-1.1.el3.rf.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/perl-XML-Stream-1.22-1.1.el3.rf.noarch.rpm
if [ ! -f "perl-XML-Stream-1.22-1.1.el3.rf.noarch.rpm" ]
then
	echo 
	echo ERROR: perl-XML-Stream-1.22-1.1.el3.rf.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST perl-XML-Stream-1.22-1.1.el3.rf.noarch.rpm"
			
					
				
				
	 			
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-server-4.1.11-0.i386.rpm
if [ ! -f "MySQL-server-4.1.11-0.i386.rpm" ]
then
	echo 
	echo ERROR: MySQL-server-4.1.11-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST MySQL-server-4.1.11-0.i386.rpm"
				
					  			  
	  			
wget -N -nv http://glite.web.cern.ch/glite/packages/externals/bin/rhel30/RPMS/MySQL-client-4.1.11-0.i386.rpm
if [ ! -f "MySQL-client-4.1.11-0.i386.rpm" ]
then
	echo 
	echo ERROR: MySQL-client-4.1.11-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST MySQL-client-4.1.11-0.i386.rpm"
				
				
			

	# Download glite-voms-service RPMS from repository
		
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-config-1.6.22-1.noarch.rpm
if [ ! -f "glite-config-1.6.22-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-config-1.6.22-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-config-1.6.22-1.noarch.rpm"
			
			
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-voms-server-mysql-config-2.2.5-1.noarch.rpm
if [ ! -f "glite-voms-server-mysql-config-2.2.5-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-voms-server-mysql-config-2.2.5-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-voms-server-mysql-config-2.2.5-1.noarch.rpm"
			

				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-api-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-api-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-api-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-api-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-api-c-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-api-c-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-api-c-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-api-c-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-api-cpp-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-api-cpp-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-api-cpp-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-api-cpp-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-clients-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-clients-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-clients-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-clients-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-config-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-config-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-config-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-config-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-server-1.6.10-0.i386.rpm
if [ ! -f "glite-security-voms-server-1.6.10-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-server-1.6.10-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-server-1.6.10-0.i386.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-security-voms-admin-client-1.2.10-1.noarch.rpm
if [ ! -f "glite-security-voms-admin-client-1.2.10-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-admin-client-1.2.10-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-admin-client-1.2.10-1.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-security-voms-admin-server-1.2.10-1.noarch.rpm
if [ ! -f "glite-security-voms-admin-server-1.2.10-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-admin-server-1.2.10-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-admin-server-1.2.10-1.noarch.rpm"
				
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-security-voms-admin-interface-1.0.2-1.noarch.rpm
if [ ! -f "glite-security-voms-admin-interface-1.0.2-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-admin-interface-1.0.2-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-admin-interface-1.0.2-1.noarch.rpm"
			
										
				
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-security-trustmanager-1.8.2-1.noarch.rpm
if [ ! -f "glite-security-trustmanager-1.8.2-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-trustmanager-1.8.2-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-trustmanager-1.8.2-1.noarch.rpm"
			
					
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/noarch/RPMS/glite-security-util-java-1.3.0-1.noarch.rpm
if [ ! -f "glite-security-util-java-1.3.0-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-util-java-1.3.0-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-util-java-1.3.0-1.noarch.rpm"
			
					
				
				
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/bin/rhel30/i386/RPMS/glite-security-voms-mysql-1.1.2-0.i386.rpm
if [ ! -f "glite-security-voms-mysql-1.1.2-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-security-voms-mysql-1.1.2-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-voms-mysql-1.1.2-0.i386.rpm"
			
			
	
	# Download glite-rgma-servicetool scripts from repository
	
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/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 glite-security-utils scripts from repository
	
wget -N -nv http://glite.web.cern.ch/glite/packages/R1.5/R20051130/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 dependencies RPMS from repository
		

	# Download glite-security-utils RPMS from repository
		
	
	#Download and install subservices
    parseScriptList
		
	# Install all RPMS
	echo
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo "x Please wait, installing the gLite VOMS Server (MySQL) ...           x"
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	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 "You can find further information in the Installation guide."
		echo
		echo "Before using the gLite VOMS Server (MySQL):"
		echo
		echo "(1) Install Java"
		echo
		echo "    Due to license restrictions we cannot redistribute Java."
		echo "    Please refer to the installation guide for information"
		echo "    about the version."
		echo
		echo "(2) 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 VOMS Server node and publish it"
		echo "       A template for site configuration of a typical"
		echo "       gLite VOMS Server node is provided in"
		echo "           /opt/glite/etc/config/templates/glite-voms-server-site-config.xml"
		echo
		echo "    b) Local configuration:"
		echo "       Create or update the VOMS Server configuration file"
		echo "           /opt/glite/etc/config/glite-voms-server-mysql.cfg.xml ,"		
		echo "       the gLite Security Utilities configuration file"
		echo "           /opt/glite/etc/config/glite-security-utils.cfg.xml"
		echo "       the R-GMA common configuration file"
		echo "           /opt/glite/etc/config/glite-rgma-common.cfg.xml"
		echo "       the R-GMA servicetool configuration file"
		echo "           /opt/glite/etc/config/glite-rgma-servicetool.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 "(3) Configure MySQL"
		echo
		echo "       If you have not done it already, set up the MySQL database root"
		echo "       password via:"
		echo "              /usr/bin/mysqladmin -u root password 'yourPassword'"
		echo "              /usr/bin/mysqladmin -u root -h your.host.name password 'yourPassword'"
		echo "       and make sure you have specified the correct password in the configuration files."
		echo
		echo "(4) Configure and start the VOMS Server"
		echo
		echo "    Run the configuration script /opt/glite/etc/config/scripts/glite-voms-server-config.py"
		echo "    with the option --configure to configure the service and then with the option --start"
		echo "    to start the service."
		echo
	else
		echo
		echo
		echo An error occurred while installing the VOMS Server 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 glite-bugs@cern.ch

	cd ..
}

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

	# Global dependencies	
	

	# glite-voms-service dependencies RPMS from repository
		
				
RPMLIST="$RPMLIST gpt-VDT1.2.2rh9-1"
			
					
				
RPMLIST="$RPMLIST vdt_globus_essentials-VDT1.2.2rh9-1"
			
										  			  
				
RPMLIST="$RPMLIST tomcat5-5.0.28-11_EGEE"
			
					
				
RPMLIST="$RPMLIST perl-Crypt-SSLeay-0.51-4"
			 	
						
				
RPMLIST="$RPMLIST perl-Authen-SASL-2.08-1.1.el3.rf"
			
					
				
RPMLIST="$RPMLIST perl-Digest-HMAC-1.01-11.1"
			
					
				
RPMLIST="$RPMLIST perl-Digest-SHA1-2.01-15.1"
			
					
				
RPMLIST="$RPMLIST perl-MIME-Lite-2.117-2.1.el3.rf"
			
					
				
RPMLIST="$RPMLIST perl-Net-Jabber-2.0-1.1.el3.rf"
			
					
				
RPMLIST="$RPMLIST perl-Net-XMPP-1.0-1.1.el3.rf"
			
					
				
RPMLIST="$RPMLIST perl-SOAP-Lite-0.60a-1.1.el3.rf"
			
					
				
RPMLIST="$RPMLIST perl-XML-Stream-1.22-1.1.el3.rf"
			
					
				
				
	 			
RPMLIST="$RPMLIST MySQL-server-4.1.11-0"
				
					  			  
	  			
RPMLIST="$RPMLIST MySQL-client-4.1.11-0"
				
				
			

	# glite-voms-service RPMS from repository
		
				
RPMLIST="$RPMLIST glite-config-1.6.22-1"
			
			
				
RPMLIST="$RPMLIST glite-voms-server-mysql-config-2.2.5-1"
			

				
RPMLIST="$RPMLIST glite-security-voms-api-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-api-c-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-api-cpp-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-clients-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-config-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-server-1.6.10-0"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-admin-client-1.2.10-1"
			
					
				
RPMLIST="$RPMLIST glite-security-voms-admin-server-1.2.10-1"
				
					
				
RPMLIST="$RPMLIST glite-security-voms-admin-interface-1.0.2-1"
			
										
				
				
RPMLIST="$RPMLIST glite-security-trustmanager-1.8.2-1"
			
					
				
RPMLIST="$RPMLIST glite-security-util-java-1.3.0-1"
			
					
				
				
RPMLIST="$RPMLIST glite-security-voms-mysql-1.1.2-0"
			
			

	# glite-rgma-servicetool dependencies RPMS from repository
		

	# glite-rgma-servicetool RPMS from repository
		

	# glite-security-utils dependencies RPMS from repository
		

	# glite-security-utils RPMS from repository
		
		
	# Uninstall all RPMS
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo "x  Please wait, uninstalling the gLite VOMS server (MySQL) ...           x"
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo
	rpm -ev $RPMLIST
	if [ "$?" == "0" ]; then
		echo
		echo Done!
	else
		echo
		echo An error occurred while removing the VOMS Server 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-voms-server-mysql_installer v. 2.2.5
	echo 
	echo "The glite-voms-server-mysql_installer installs the gLite VOMS Server and Admin Tools (MySQL version)"
	echo 
	echo Usage: glite-voms-server-mysql_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-voms-server-mysql_installer v. 2.2.5
	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
	

