
#!/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-service-discovery_installer v. 1.0.0
#
# The glite-service-discovery_installer installs the gLite service discovery
#
# Usage: glite-service-discovery_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 SCRIPTLIST to execute all scripts
function parseScriptList()
{
        for i in $SCRIPTLIST
        do
        		if [ "$INSTALL" = "true" ]; then
        			if [ "${basedir}" != "" ]; then
        				$i --basedir $basedir
        			else
	                	$i
	                fi
	            else
	            	$i -u
	            fi
        done
}


#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
}

function parseUserRPMList()
{
        newRPMLIST=""
        localRPMLIST=`rpm -qa --dbpath $basedir/.rpm`
        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
}

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

	INSTALL=true

	version
	echo
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo x Please wait, downloading the gLite service discovery ... x
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo

        mkdir -p glite-service-discovery
        cd glite-service-discovery

	# Download global dependencies	
	
 	

	# Download glite-service-discovery scripts from repository
			
		
	# Download glite-service-discovery dependencies RPMS from repository
						
				
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/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/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/glite-essentials-java-1.2.0-2_EGEE.noarch.rpm
if [ ! -f "glite-essentials-java-1.2.0-2_EGEE.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-essentials-java-1.2.0-2_EGEE.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-essentials-java-1.2.0-2_EGEE.noarch.rpm"
			 
								
				
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"
			
			

	# Download glite-service-discovery RPMS from repository
		
			
				
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-config-1.2.1-1.noarch.rpm
if [ ! -f "glite-config-1.2.1-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-config-1.2.1-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-config-1.2.1-1.noarch.rpm"
			
				
				
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-service-discovery-config-1.0.0-1.noarch.rpm
if [ ! -f "glite-service-discovery-config-1.0.0-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-config-1.0.0-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-config-1.0.0-1.noarch.rpm"
			
                	          	
				
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-service-discovery-api-c-2.0.0-0.i386.rpm
if [ ! -f "glite-service-discovery-api-c-2.0.0-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-api-c-2.0.0-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-api-c-2.0.0-0.i386.rpm"
			
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-service-discovery-api-java-2.0.1-1.noarch.rpm
if [ ! -f "glite-service-discovery-api-java-2.0.1-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-api-java-2.0.1-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-api-java-2.0.1-1.noarch.rpm"
			
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-service-discovery-bdii-c-2.0.1-1.i386.rpm
if [ ! -f "glite-service-discovery-bdii-c-2.0.1-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-bdii-c-2.0.1-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-bdii-c-2.0.1-1.i386.rpm"
			
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-service-discovery-cli-2.0.0-1.i386.rpm
if [ ! -f "glite-service-discovery-cli-2.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-cli-2.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-cli-2.0.0-1.i386.rpm"
				
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-service-discovery-file-c-2.0.0-1.i386.rpm
if [ ! -f "glite-service-discovery-file-c-2.0.0-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-file-c-2.0.0-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-file-c-2.0.0-1.i386.rpm"
							
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-service-discovery-rgma-c-2.0.1-0.i386.rpm
if [ ! -f "glite-service-discovery-rgma-c-2.0.1-0.i386.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-rgma-c-2.0.1-0.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-rgma-c-2.0.1-0.i386.rpm"
				
			
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-service-discovery-rgma-java-2.0.1-1.noarch.rpm
if [ ! -f "glite-service-discovery-rgma-java-2.0.1-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-service-discovery-rgma-java-2.0.1-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-service-discovery-rgma-java-2.0.1-1.noarch.rpm"
			

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

				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/i386/RPMS/glite-rgma-api-cpp-4.1.14-1.i386.rpm
if [ ! -f "glite-rgma-api-cpp-4.1.14-1.i386.rpm" ]
then
	echo 
	echo ERROR: glite-rgma-api-cpp-4.1.14-1.i386.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-rgma-api-cpp-4.1.14-1.i386.rpm"
			
					
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-rgma-base-4.1.19-1.noarch.rpm
if [ ! -f "glite-rgma-base-4.1.19-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-rgma-base-4.1.19-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-rgma-base-4.1.19-1.noarch.rpm"
			
					
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-rgma-api-java-4.1.5-1.noarch.rpm
if [ ! -f "glite-rgma-api-java-4.1.5-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-rgma-api-java-4.1.5-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-rgma-api-java-4.1.5-1.noarch.rpm"
				
					
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-security-trustmanager-1.7.3-1.noarch.rpm
if [ ! -f "glite-security-trustmanager-1.7.3-1.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-trustmanager-1.7.3-1.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-trustmanager-1.7.3-1.noarch.rpm"
									
					
				
wget -N --non-verbose http://glite.web.cern.ch/glite/packages/R1.2/R20050715/bin/rhel30/noarch/RPMS/glite-security-util-java-1.1.2-2.noarch.rpm
if [ ! -f "glite-security-util-java-1.1.2-2.noarch.rpm" ]
then
	echo 
	echo ERROR: glite-security-util-java-1.1.2-2.noarch.rpm could not be downloaded!
	exit 1
fi
RPMLIST="$RPMLIST glite-security-util-java-1.1.2-2.noarch.rpm"
															
				
			
	# Install all RPMS
	echo
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo x Please wait, installing the gLite service discovery ... x
	echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	echo
	parseScriptList
	parseRPMList
	if [ ! -z "$RPMLIST" ]; then
		if [ `id -u` == 0 ]; then		
			rpm -Uvh $RPMLIST
			rpm_return=$?
		else
			echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			echo x User installation
			echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			if [ !  -d $basedir/.rpm ]; then
				mkdir -p $basedir/.rpm
				#cp -R /var/lib/rpm/* $basedir
				rpm --initdb --dbpath $basedir/.rpm
				
				touch $basedir/.rpm/packages.sort
			fi
			rpm -qa | sort > $basedir/.rpm/packages.sort~
			diff  $basedir/.rpm/packages.sort $basedir/.rpm/packages.sort~ > /dev/null
			if [ $? != 0 ]; then
					#######################################
					#	Create system.rpm file
					#######################################
					echo Installer is inspecting your installation. It might take a while
					# creation of the system.rpm file
	
					for package in `rpm -qa`
					do
	        			#echo $package
	        			rpm -q --provides $package >> /tmp/provides
					done
					datestamp=`date +%Y%m%d%H%M`
					###############
					#       Create .spec file
					##############
					echo "Summary:Provides root installed symbols" > system.spec
					echo "Name:system" >> system.spec
					echo "Version:0.1.0" >> system.spec
					echo "Release:$datestamp" >> system.spec
					echo "Copyright:Open Source EGEE License" >> system.spec
					echo "Vendor:EU EGEE project" >> system.spec
					echo "Group:System/Application" >> system.spec
					echo "BuildArch:noarch" >> system.spec
					echo "BuildRoot:%{_builddir}/%{name}-%{version}" >> system.spec
					echo "Source:system.tar.gz" >> system.spec
					echo "Provides:/bin/sh" >> system.spec
					echo "Provides:/usr/bin/env" >> system.spec
                    echo "Provides:/usr/bin/perl" >> system.spec
                    echo "Provides:/bin/env" >> system.spec
                    echo "Provides:/sbin/ldconfig" >> system.spec
                    echo "Provides:/sbin/install-info" >> system.spec
                    echo "Provides:/bin/bash" >> system.spec
                    echo "Provides:/bin/csh" >> system.spec

					grep -v ">" /tmp/provides | sed -e 's/.*\/\(.*\)/\1/g' | sort | uniq > /tmp/provides.uniq
					sed -e 's/\(.*\)/Provides:\1/g' /tmp/provides.uniq >> system.spec
					
					echo "%define debug_package %{nil}" >> system.spec

					echo "%description" >> system.spec
					echo "gLite UI installation" >> system.spec
					#echo "%prep" >> system.spec
					#echo "%setup -c" >> system.spec
					#echo "%build" >> system.spec
					#echo "%install" >> system.spec
					echo "%clean" >> system.spec
					echo "%pre" >> system.spec
					echo "%post" >> system.spec
					echo "%preun" >> system.spec
					echo "%postun" >> system.spec
					echo "%files" >> system.spec
					echo "%changelog" >> system.spec
					echo >> system.spec

					if [ -f $HOME/.rpmmacros ]; then
						mv $HOME/.rpmmacros $HOME/.rpmmacros~
					fi
					echo %_topdir        $basedir/.rpm/rpmbuild >> $HOME/.rpmmacros
					mkdir -p $basedir/.rpm/rpmbuild/SPECS
					mkdir -p $basedir/.rpm/rpmbuild/SOURCES
					mkdir -p $basedir/.rpm/rpmbuild/BUILD
					mkdir -p $basedir/.rpm/rpmbuild/RPMS
					touch $basedir/.rpm/rpmbuild/SOURCES/system.tar.gz
					rpmbuild -bb system.spec
					if [ -f $HOME/.rpmmacros~ ]; then
						mv $HOME/.rpmmacros~ $HOME/.rpmmacros
					fi
					
					######################################
					#	Update system.rpm file in the database
					######################################
					rpm -U --dbpath $basedir/.rpm $basedir/.rpm/rpmbuild/RPMS/noarch/system-0.1.0-$datestamp.noarch.rpm
					######################################
					#	Update package.list file
					#######################################
					mv $basedir/.rpm/packages.sort~ $basedir/.rpm/packages.sort
					#########################################
					#	Cleanup of not needed files
					#########################################
					rm -rf $basedir/.rpm/rpmbuild
					rm -f /tmp/provides /tmp/provides.uniq
			fi 
			
			parseUserRPMList
			if [ ! -z "$RPMLIST" ]; then
				rpm -Uvh --relocate /opt/glite=$basedir\
					 --relocate /opt/globus=$basedir\
					 --relocate /opt/gpt=$basedir\
			 		--relocate /usr=$basedir/usr\
			 		--relocate /etc=$basedir/etc\
			 		--noscripts --dbpath $basedir/.rpm $RPMLIST
				rpm_return=$?
			else
				echo All required RPMS are already installed
				rpm_return=0
			fi
			
			if [ $rpm_return != 0 ]; then
				break
			fi
			###############################################
			#	Fixed hardcoded absolute path in .la files
			###############################################
			for la in `find $HOME/$prefix -name "*.la"`
			do
    			REPL=`echo ${la} | sed -e 's/\(.*\)\/.*$/\1/g'`
    			sed -i~ -e "s|^libdir=.*|libdir=${REPL}|g"  ${la} 
			done
		fi
	else
		echo All required RPMS are already installed
		rpm_return=0
	fi
	if [ "$rpm_return" == "0" ]; then
		echo
		echo Done!
		echo
		echo The default installation is to \$GLITE_LOCATION=/opt/glite		
		echo 
	else
		echo
		echo An error occurred while installing the service discovery 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.
		echo
	fi	
	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-service-discovery scripts from repository
		

	# glite-service-discovery dependencies RPMS from repository
						
				
RPMLIST="$RPMLIST vdt_globus_info_essentials-VDT1.2.2rh9-1"
					

				
RPMLIST="$RPMLIST vdt_globus_essentials-VDT1.2.2rh9-1"
					

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

				
RPMLIST="$RPMLIST glite-essentials-java-1.2.0-2_EGEE"
					 
								
				
RPMLIST="$RPMLIST glite-essentials-cpp-1.1.1-1_EGEE"
					
			

	# glite-service-discovery RPMS from repository
		
			
				
				
RPMLIST="$RPMLIST glite-config-1.2.1-1"
                                        
				
				
				
RPMLIST="$RPMLIST glite-service-discovery-config-1.0.0-1"
                                        
                	          	
				
				
RPMLIST="$RPMLIST glite-service-discovery-api-c-2.0.0-0"
                                        
			
				
RPMLIST="$RPMLIST glite-service-discovery-api-java-2.0.1-1"
                                        
			
				
RPMLIST="$RPMLIST glite-service-discovery-bdii-c-2.0.1-1"
                                        
			
				
RPMLIST="$RPMLIST glite-service-discovery-cli-2.0.0-1"
                                        	
			
				
RPMLIST="$RPMLIST glite-service-discovery-file-c-2.0.0-1"
                                        				
			
				
RPMLIST="$RPMLIST glite-service-discovery-rgma-c-2.0.1-0"
                                        	
			
				
RPMLIST="$RPMLIST glite-service-discovery-rgma-java-2.0.1-1"
                                        

				
				
RPMLIST="$RPMLIST glite-rgma-api-c-4.1.11-1"
                                        

				
RPMLIST="$RPMLIST glite-rgma-api-cpp-4.1.14-1"
                                        
					
				
RPMLIST="$RPMLIST glite-rgma-base-4.1.19-1"
                                        
					
				
RPMLIST="$RPMLIST glite-rgma-api-java-4.1.5-1"
                                        	
					
				
RPMLIST="$RPMLIST glite-security-trustmanager-1.7.3-1"
                                        						
					
				
RPMLIST="$RPMLIST glite-security-util-java-1.1.2-2"
                                        												
				
			
		
	# Uninstall all RPMS
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo "x  Please wait, uninstalling the gLite R-GMA client ...   x"
	echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	echo
	rpm -ev $RPMLIST
	if [ "$?" == "0" ]; then
		echo
		echo Done!
	else
		echo
		echo An error occurred while removing the R-GMA client 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-service-discovery_installer v. 1.0.0
	echo 
	echo The glite-service-discovery_installer installs the gLite service discovery
	echo 
	echo Usage: glite-service-discovery_installer \[-u\|-v\|--help\]
	echo -u          uninstall
	echo -v          print version
	echo --help      print script usage info
	echo --basedir	 set the base directory for the user installation
	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-service-discovery_installer v. 1.0.0
	echo 
}


RPMLIST=

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

TEMP=`getopt -o uvh --long uninstall,version,help,basedir: \
     -n 'glite-service-discovery_installer.sh' -- "$@"`

if [ $? != 0 ] ; then echo "Terminating..." ; exit 1 ; fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

# no basedir default since this module is not supposed to be installed individually

while true ; do
        case "$1" in
                -u|--uninstall) uninstall
                				exit 0
                				;;
                -v|--version)	version
                				exit 0
                				;;
                -h|--help)		usage
                				exit 0
                				;;
                --basedir) 		export basedir=$2
                				echo Setting base directory to $prefix
                				shift 2; break ;;
#                *) echo "Internal error!" ; exit 1 ;;
				*) break ;;
        esac
done

install

exit 0
	
