Shell Script for re-installation of open office

Below is the script for open office automatic re-installation, there are different versions on different servers the below script will check the version of the
openoffice and will reinstall the same version(downloading for httpd server) the below code looks lengthy can we make it short

#!/bin/bash
# Bash Menu for OPENOFFICE Installation
 
rpm -qa | egrep "^ooo|openoffice" | grep 3.3.0-9567
if [ $? -eq 0 ]
then
echo "############this is a Server version openoffice3.3.0#################"
sleep 3
rpm -qa | egrep "^ooo|openoffice" | xargs sudo rpm -e
cd /opt
rm -rf /opt/openoffice.org3 /opt/openoffice.org  /opt/OOO330_m20_native_packed-1_en-US.9567
sleep 5
#wget http://192.168.64.13/OOo_3.3.0_Linux_x86-64_install-rpm-wJRE_en-US.tar.gz
tar -xvf OOo_3.3.0_Linux_x86-64_install-rpm-wJRE_en-US.tar.gz
cd /opt/OOO330_m20_native_packed-1_en-US.9567/RPMS
rm -rf jre*
rpm -ivh *.rpm
sleep 3
cd desktop-integration/
rpm -ivh openoffice.org3.3-redhat-menus-3.3-9556.noarch.rpm
echo "####################openoffice3.3.0 installed####################"
rm -rf /opt/OOO330_m20_native_packed-1_en-US.9567
exit 0
fi
rpm -qa | egrep "^ooo|openoffice" | grep 3.4.1-9593
if [ $? -eq 0 ]
then
echo "##################this is a Server version openoffice3.4.1####################"
sleep 3
rpm -qa | egrep "^ooo|openoffice" | xargs sudo rpm -e
cd /opt 
rm -rf /opt/en-US/ /opt/openoffice.org /opt/openoffice.org3/
sleep 3
#wget  http://192.168.64.13/Apache_OpenOffice_incubating_3.4.1_Linux_x86-64_install-rpm_en-US.tar.gz
tar -xvf Apache_OpenOffice_incubating_3.4.1_Linux_x86-64_install-rpm_en-US.tar.gz
cd en-US/RPMS
rpm -ivh *.rpm
sleep 3
cd desktop-integration/
rpm -ivh openoffice.org3.4-redhat-menus-3.4-9593.noarch.rpm
echo "#####################openoffice3.4.1 installed#####################"
rm -rf /opt/en-US/
exit 0
fi 
rpm -qa | egrep "^ooo|openoffice" | grep 4.0.0-9702
if [ $? -eq 0 ]
then
echo "################################this is a Server version openoffice4.0.0##################"
sleep 3
rpm -qa | egrep "^ooo|openoffice" | xargs sudo rpm -e
cd /opt
rm -rf /opt/en-US/  /opt/openoffice4/
sleep 3
#wget http://192.168.64.13/Apache_OpenOffice_4.0.0_Linux_x86-64_install-rpm_en-US.tar.gz
tar -xvf Apache_OpenOffice_4.0.0_Linux_x86-64_install-rpm_en-US.tar.gz
cd en-US/RPMS
rpm -ivh *.rpm
sleep 3
cd desktop-integration/
rpm -ivh openoffice4.0-redhat-menus-4.0-9702.noarch.rpm
echo "#############openoffice4.0.0 installed##############"
rm -rf /opt/en-US/
exit 0
fi
rpm -qa | egrep "^ooo|openoffice"| grep 4.1.0-9764
if [ $? -eq 0 ]
then
echo "##################this is a Server version openoffice4.1.0####################"
sleep 5
rpm -qa | egrep "^ooo|openoffice" | xargs sudo rpm -e 
cd /opt
rm -rf /opt/en-US/  /opt/openoffice4/
sleep 3
#wget http://192.168.64.13/Apache_OpenOffice_4.1.0_Linux_x86-64_install-rpm_en-US.tar.gz
tar -xvf Apache_OpenOffice_4.1.0_Linux_x86-64_install-rpm_en-US.tar.gz
cd en-US/RPMS
rpm -ivh *.rpm
sleep 3
cd desktop-integration/
rpm -ivh openoffice4.1-redhat-menus-4.1-9764.noarch.rpm
echo "######################openoffice4.1.0 installed############################"
rm -rf /opt/en-US/
exit 0
fi
rpm -qa | egrep "^ooo|openoffice"| grep 4.1.1-9775
if [ $? -eq 0 ]
then
echo "####################this is a Server version openoffice4.1.1################"
sleep 5
rpm -qa | egrep "^ooo|openoffice" | xargs sudo rpm -e 
cd /opt
rm -rf /opt/en-US/  /opt/openoffice4/
sleep 3
#wget http://192.168.64.13/Apache_OpenOffice_4.1.1_Linux_x86-64_install-rpm_en-US.tar.gz
tar -xvf Apache_OpenOffice_4.1.1_Linux_x86-64_install-rpm_en-US.tar.gz
cd en-US/RPMS
rpm -ivh *.rpm
sleep 3
cd desktop-integration/
rpm -ivh openoffice4.1.1-redhat-menus-4.1.1-9775.noarch.rpm
echo "###################openoffice4.1.1 installed###############"
rm -rf /opt/en-US/
exit 0
fi
exit

are you having problems with this script?
are you having performance issues?
what do you mean by making the script short?

explain your problem clearly..

This looks little lenghty thinking can't this be made short using case etc.

Hello James,
you can re-write this into a function by passing the open office version number as an argument to it and re-use it for any version.
we would like to encourage you to re-write the script and let us know, if you face any problems on the event of re-writing.