Last active
April 24, 2018 20:17
-
-
Save dawngerpony/e61c846f2b3fb94e13e6a420b5eb074d to your computer and use it in GitHub Desktop.
Run this script with a tnsnames.ora file as the only parameter to install instantclient version 12.2.0.1.0-2 (once you have downloaded the files from Oracle of course).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## https://oraclespin.com/2018/01/25/install-sqlplus-instant-client-on-macos/ | |
VERSION="12.2.0.1.0-2" | |
FILES="instantclient-basic-macos.x64-$VERSION.zip instantclient-sqlplus-macos.x64-$VERSION.zip instantclient-sdk-macos.x64-$VERSION.zip" | |
INSTALL_DIR="instantclient_12_2" | |
if [ $# -lt 1 ]; then | |
echo "Specify tnsnames.ora location" | |
exit 1 | |
fi | |
TNSNAMES=$1 | |
function clean() { | |
echo "Cleaning up..." | |
for f in $FILES; do | |
if [ ! -f $f ]; then | |
echo "Missing file $f" | |
exit 1 | |
fi | |
done | |
if [ -d $HOME/$INSTALL_DIR ]; then | |
rm -rf $HOME/$INSTALL_DIR | |
fi | |
if [ -d $INSTALL_DIR ]; then | |
rm -rf $INSTALL_DIR | |
fi | |
if [ -f /usr/local/lib/libclntsh.dylib ]; then | |
sudo rm /usr/local/lib/libclntsh.dylib | |
fi | |
if [ -f /usr/local/lib/libclntsh.dylib.12.1 ]; then | |
sudo rm /usr/local/lib/libclntsh.dylib.12.1 | |
fi | |
echo "Done." | |
} | |
clean | |
unzip instantclient-basic-macos.x64-$VERSION.zip | |
cd instantclient_12_2 && unzip -j ../instantclient-sqlplus-macos.x64-$VERSION.zip && cd .. | |
mv $INSTALL_DIR $HOME | |
mkdir -p $HOME/instantclient_12_2/network/admin | |
sudo ln -s ~/instantclient_12_2/libclntsh.dylib /usr/local/lib/ | |
sudo ln -s ~/instantclient_12_2/libclntsh.dylib.12.1 /usr/local/lib/ | |
ls -l /usr/local/lib/ | grep $HOME | |
export PATH=$HOME/instantclient_12_2:$PATH | |
export TNS_ADMIN=$HOME/instantclient_12_2/network/admin | |
cd $TNS_ADMIN | |
cp $TNSNAMES . | |
export ORACLE_HOME=$HOME/$INSTALL_DIR | |
export DYLD_LIBRARY_PATH=$ORACLE_HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment