#!/bin/sh

#
# ENSURE WE HAVE INI FILES
#
# Upon a fresh install of OSX these files do not exist. The
# ODBC Installer library calls should create these files for
# us when we do stuff like request to register a driver but
# this does not seem to happen and the request fails. So we
# we start by making sure we have some, mostly, empty ini
# files in place before we make installer calls.
#
# Also note that there are many places where these ini files
# *could* go based upon the search algorythm in the default
# ODBC system or any other ODBC system which may get 
# installed. We choose the following because they seem to be
# the ones created when we use the standard ODBC Admin.
# GUI application.
# 
if [ ! -f ~/Library/ODBC ]; then
    mkdir ~/Library/ODBC
    chmod 777 ~/Library/ODBC
    cp *.ini ~/Library/ODBC
fi

#
# LOOSEN THE PRIVS
#
# This has to be done because MYODBCConfig will run as normal
# user.
#
chmod 664 ~/Library/ODBC/odbcinst.ini
chmod 664 ~/Library/ODBC/odbc.ini

#
# REGISTER THE DRIVER
#
myodbcinst -i

#
# CREATE A SAMPLE DSN
#
myodbcinst -s

#
# ALLOW USER TO EDIT SAMPLE DSN
#
# This invokes a GUI interface to make it easier for a novice
# to get started with myodbc.
#
# We could do the same thing with "myodbcinst -e -g" but 
# MYODBCConfig integrates better with the OSX GUI.
#
# open /Applications/Utilities/MYODBCConfig.app
/Applications/Utilities/MYODBCConfig.app/Contents/MacOS/MYODBCConfig


