#!/bin/sh

#################################################
# 												#
#			    MacSqlPlus v1.1  				#	
#												#
# Script realized by Danilo Vizzarro			#
# You can find the step-by-step instructions on #
# www.danilovizzarro.it							#
# v1.1 - 14-FEB-2011							#
#################################################

# 1. You need to be logged as root
# 2. You need to download the Oracle Client from the Oracle website and save it on your desktop

clear
echo "*******************************************************************"
echo "*                       MacSqlPlus v1.1                           *"
echo "*******************************************************************"
echo "* The script will install SqlPlus on your Mac.                    *" 
echo "* You can find the updated version of the code, a video demo      *"
echo "* and a step-by-step tutorial on www.danilovizzarro.it/?p=10      *"
echo "* Script tested on Mac OS X running Leopard 10.5.4                *"
echo "* Script created by Danilo Vizzarro.                              *"
echo "*******************************************************************"

if [ $USER == root ]
then 
  
mkdir -p /opt/oracle
cd /opt/oracle
cp /var/root/*.zip /opt/oracle
unzip \*.zip
cd /opt/oracle/instantclient_10_2

cp /etc/profile ~/.profile
cp /etc/profile ~/.profile.backup

echo "" >> ~/.profile
echo "DYLD_LIBRARY_PATH=\"/opt/oracle/instantclient_10_2\"" >> ~/.profile
echo "export DYLD_LIBRARY_PATH" >> ~/.profile
echo "" >> ~/.profile
echo "TNS_ADMIN=\"/opt/oracle/tns\"" >> ~/.profile
echo "export TNS_ADMIN" >> ~/.profile
echo "" >> ~/.profile
echo "ORACLE_HOME=\"/opt/oracle/instantclient_10_2\"" >> ~/.profile
echo "export ORACLE_HOME" >> ~/.profile

ln -s /opt/oracle/instantclient_10_2/sqlplus /usr/bin/sqlplus

echo ""
echo "You can now execute the script TNSconnect.sh to set up the tnsnames.ora"
echo "After that you can connect your Oracle DB via Sqlplus using this command:"
echo "sqlplus DB_USER/DB_PASS@//DB_SERVER:DB_PORT/DB_SID"
echo ""

else
echo "Please log in as root and execute again the script."
echo ""
fi
