#!/bin/sh
#
# Copyright (c) 1993-2002 Easysoft Ltd. All rights reserved.
#
# ./install [skip]
# skip is a string of characters representing the parts of this install
# to skip.
# c - client
# s - server
# l - licensing
# u - unixODBC
#
# $Id: install,v 1.101 2002/01/22 11:42:53 martin Exp $
#
# $Log: install,v $
# Revision 1.101  2002/01/22 11:42:53  martin
# Copyright message change.
#
# Revision 1.100  2001/12/10 14:45:26  martin
# irix changes.
#
# Revision 1.99  2001/12/04 15:52:21  martin
# Formatting changes only.
#
# Revision 1.98  2001/11/26 17:08:16  martin
# Support MAC OS X / darwin.
#
# Revision 1.97  2001/11/21 11:41:22  martin
# Fix bug IDs 1178 - tar extraction warnings on unixware due to failure
# 	to set the owner/group on the extracted files to the same as they are
# 	in the tar file.
# Fix bug ID 1233 - if md5sum is not present on a machine this install
# 	script attempts to echo that fact to the screen but the echo
# 	command is missing - this leads to a few shell errors being displayed
# 	although does not usually stop the install.
#
# Revision 1.96  2001/11/12 10:00:41  martin
# Remove note about free licenses.
#
# Revision 1.95  2001/09/05 07:37:54  martin
# Add return status from uodbc/install_paths if they fail.
#
# Revision 1.94  2001/08/13 13:38:04  martin
# Fix problem with previous change (else if instead of elif).
#
# Revision 1.93  2001/08/08 10:08:50  martin
# If unixODBC exists but we did not install it still offer to
# 	install the OOB client and demo DSN under unixODBC.
#
# Revision 1.92  2001/08/01 12:47:15  martin
# Add support for Unixware 2.1.3.
#
# Revision 1.91  2001/07/12 14:02:22  martin
# Exiting too early after server install fails to show postinstall.
#
# Revision 1.90  2001/07/12 13:13:59  martin
# Add SunOS specific checks.
#
# Revision 1.89  2001/06/28 13:09:04  martin
# Add extra line - ECHO.
#
# Revision 1.88  2001/05/10 14:30:35  martin
# Also skip common parts of install if skipping client and server.
#
# Revision 1.87  2001/05/09 10:15:26  martin
# Add install script parameter to allow skipping some actions.
# Change the format of the output oob_install.info file for compatability
# 	with new combined isam install.
# Output warning if we failed to install/locate unixODBC.
# Added note about the OOB client not being a native driver.
# Add note just before obtaining license about one free connection.
#
# Revision 1.86  2001/04/04 10:13:36  martin
# Add easysoft/bin to list of dirs created.
#
# Revision 1.85  2001/03/27 14:26:20  martin
# Add check for installed SQIs and issue possible incompatability warning.
#
# Revision 1.84  2001/03/22 12:49:46  martin
# bug ID 1090 - install fails if no tee command.
# 	install_check_tools looks for system tee and if none falls back
# 	on included simple tee shell.
#
# Revision 1.83  2001/03/22 11:16:20  martin
# Make sure the dir install script is running in is world writeable
#      as some install scripts create files in the cwd.
# bug ID 1091. If installer chose non-default install dir and
# 	/usr/local/easysoft does not exist the install script still
# 	attempts to move it out of the way. This leads to a harmless mv
# 	error.
#
# Revision 1.82  2001/02/23 16:44:09  martin
# GNU tar returns error correctly.
#
# Revision 1.81  2001/02/23 12:39:31  martin
# PSARGS got accidentally changed.
#
# Revision 1.80  2001/02/23 11:40:01  martin
# set TARGIVESERR for hp.
#
# Revision 1.79  2001/02/23 11:20:47  martin
# Do not do tar stderr checking for platforms where tar returns
# 	error state.
#
# Revision 1.78  2001/02/20 15:08:22  martin
# check return status from tar in case it fails.
# Write stderr from tar extractions to a file as some tars fail, output text
# 	to stderr but do not return an error (SCO).
# At end of install, if there were warnings draw attention to them instead
# 	of simply saying the install was successful.
#
# Revision 1.77  2001/02/16 09:03:45  martin
# Removed 2000 from product name.
#
# Revision 1.76  2001/01/09 16:31:22  martin
# Separate code to install a service into a separate script.
# Add support for xinetd.
#
# Revision 1.75  2000/11/16 15:16:55  martin
# Put echo back to first found echo if \c not interpreted.
#
# Revision 1.74  2000/11/16 11:34:14  martin
# If unixODBC was installed set the default to be install OOB client
# 	under unixODBC, else default is opposite.
# Add support for thread-safe OOB client ODBC driver - i.e. installing it
# 	under unixODBC.
# Add warning if we cannot find OOB client ODBC driver when installing
# 	OOB under unixODBC.
#
# Revision 1.73  2000/10/30 15:28:22  martin
# Fix bug ID 989 - OOB server install fails to get inetd to
#      reread configuration.
#
# Revision 1.72  2000/10/04 15:07:04  martin
# Add support for unixware.
#
# Revision 1.71  2000/08/11 08:20:30  martin
# Add note saying if the GUI ODBCConfig is not used odbc.ini files can still
# 	be edited by hand to define DSNs.
#
# Revision 1.70  2000/06/27 13:41:09  martin
# Add postinstall script call at end.
#
# Revision 1.69  2000/05/26 13:45:15  martin
# Add LIBPATH for AIX.
#
# Revision 1.68  2000/04/20 09:16:12  martin
# Add paths to LIBPATH for AIX 4.2/3 built on 4.1.
#
# Revision 1.67  2000/04/12 11:16:49  martin
# Add license dir to list of subdirs possibly created.
#
# Revision 1.66  2000/03/30 13:05:06  martin
# Fix typo.
#
# Revision 1.65  2000/03/30 12:51:17  martin
# Fix bug where if unixODBC does not exist and it is not installed from
# 	this package the installer still asks if you want to install the OOB
# 	client under unixODBC.
#
# Revision 1.64  2000/03/30 10:46:44  martin
# Save installed version and date installed into installation tree.
#
# Revision 1.63  2000/03/22 18:24:33  martin
# If /usr/local/easysoft already exists then the installer prompted to
# 	continue or not. This was really a beta thing and the default is no.
# 	Change to default to yes.
#
# Revision 1.62  2000/03/21 09:07:34  martin
# Major changes to pull alot of shell out of here in to generic scripts
# 	which other Easysoft products can use.
#
# Revision 1.61  2000/03/14 09:58:55  martin
# Add OSF support.
# Define ODBCSEARCH to add system DSNs for unixODBC.
#
# Revision 1.60  2000/03/02 13:28:35  martin
# Restrict odbcinst template file names to 14 chrs or they fail on HP-UX
# 	due to unixODBC using FILENAME_MAX (14).
#
# Revision 1.59  2000/02/28 09:48:51  martin
# Using -r instead of TESTEXISTS.
# Create /etc/odbc.ini if unixODBC DSN being installed or odbcinst will fail.
#
# Revision 1.58  2000/02/22 16:33:41  martin
# Syntax fixes to previous change.
#
# Revision 1.57  2000/02/22 16:04:32  martin
# Add demo data source for unixODBC/OOB if it exists and installer wants it.
#
# Revision 1.56  2000/02/22 15:26:30  martin
# Add licshell, wrapper around licclient.
# Add SHLIB_PATH exports for HP-UX.
#
# Revision 1.55  2000/02/04 15:12:18  martin
# Fix bug ID 682 - if you answer no to installing client you still get:
#      client installed successfully message
# 	asked whether you want to install client under unixODBC
#
# Revision 1.54  2000/01/24 15:19:23  martin
# Fix bug ID 665 - some platforms have broken tr.
#
# Revision 1.53  2000/01/12 16:26:42  martin
# Add support for sinix.
#
# Revision 1.52  2000/01/11 16:24:49  martin
# Correct grammatical error.
# Add check that install is being run from the directory created by untarring
# 	the main distribution file.
#
# Revision 1.51  1999/12/14 16:21:36  martin
# Do not use ! in if ( x ) tests, SCO does not like it.
#
# Revision 1.50  1999/12/14 14:52:03  martin
# Change all occurrances of licence to license.
#
# Revision 1.49  1999/12/14 13:53:02  martin
# Minor punctuation change.
#
# Revision 1.48  1999/12/13 17:04:01  martin
# Allow licences to be obtained at the end of the Server install.
#
# Revision 1.47  1999/12/10 14:59:57  martin
# Add Licence Client.
#
# Revision 1.46  1999/12/10 14:14:51  martin
# Fixed typo in product database string.
#
# Revision 1.45  1999/12/10 12:28:29  martin
# OOB now needs glibc 2.1.n or above.
# Add Product database reset code.
#
# Revision 1.44  1999/12/09 14:16:31  martin
# Add support for versioned shared objects. This means various Easysoft
#      products can contain the same shared objects at different versions
#      without fear of downgrading them during the install.
# Fix bug introduced with creation of license dir etc which is attempted
#      even though the server is not installed.
#
# Revision 1.43  1999/12/08 11:46:12  martin
# Fix problem on SCO where -x argument to test is not recognised.
#
# Revision 1.42  1999/12/01 17:59:41  martin
# FIx problem with script not creating licences file.
#
# Revision 1.41  1999/12/01 14:37:58  martin
# Further changes to remove double slashes from output.
# Fix typo: libdodbc -> libodbc
#
# Revision 1.40  1999/11/29 12:47:40  martin
# Add check for id.
# Create the licence dir and licences file if neccessary.
#
# Revision 1.39  1999/11/25 10:00:51  martin
# Bourne shell on Solaris needs -h to test for symbolic links and there is
# 	no -e on test, so using -r.
#
# Revision 1.38  1999/11/24 10:30:32  martin
# FreeBSD uses -h in test to test for symbolic link not -L.
# Internal bug ID 617 - double /'s shown in path in warning message.
#
# Revision 1.37  1999/11/17 10:55:31  martin
# Replace zeros in the word ODBC with O's.
# Fix a few other typos.
# Fix handling of "Define new service" question which says use 'q' and tests
# 	for 'n'.
#
# Revision 1.36  1999/11/12 10:32:20  martin
# Add stuff about licensing.
#
# Revision 1.35  1999/10/27 13:23:52  martin
# Check echo interprets backslash chrs and modify by adding -e if necessary.
#
# Revision 1.34  1999/10/27 12:01:30  martin
# FIx the path added to ld.so.conf for unixODBC to add the lib dir.
# Fix the LDLIBDIRS variable to substitute : for spaces in LDPATHLIBDIRS.
# When adding paths to ld.so.conf loop through LDLIBDIRS not LDPATHLIBDIRS.
# Ensure paths added to ld.so.conf end in newline.
# Make sure notes for esoobserver startup shell script are added to script
# 	instead of output to screen.
#
# Revision 1.33  1999/10/15 10:13:30  martin
# Incorrect path added to ld.so.conf.
#
# Revision 1.32  1999/10/14 17:14:00  martin
# If the installer does not install the server the root-continue
# 	message still pops up.
#
# Revision 1.31  1999/10/14 16:51:40  martin
# Chnage note at end of inetd startup.
#
# Revision 1.30  1999/10/14 16:31:41  martin
# Look for unixodbc tar file before asking to install it.
# If the server was not installed skip inetd/services stuff.
#
# Revision 1.29  1999/10/14 14:36:14  martin
# Create /usr/local if necessary when non-default install path chosen.
# Do not ask to install server services if server not installed.
#
# Revision 1.28  1999/10/14 13:56:27  martin
# Only offer unixODBC install if the tar file exists.
#
# Revision 1.27  1999/10/14 12:40:36  martin
# Use the testlib binary in Linux to detect the libc version instead of all
# 	that manic script.
#
# Revision 1.26  1999/10/13 10:45:29  martin
# Change Press any key messages to press return key.
# Add a check for the installer being root at the start. Warn about the
# 	consequences of not being root but still offer the installer a
# 	chance to continue.
# If the installer does not choose the default install path then symbolically
# 	link /usr/local/easysoft to install_path/easysoft.
# 	Without this binaries built with runpath will not find the shared
# 	objects.
# Fix bug in setting of LDLIBDIRS.
# OOB may be installed under unixODBC on any platform.
# Add the section on untarring the separate server files.
#
# Revision 1.25  1999/10/13 09:03:49  martin
# Change the messages saying a command is missing to be a little more friendly.
# Check for pwd.
# Check for head.
# Major change due to components of OOB being split up into multiple tar files
# 	e.g. client, common, server and unixODBC.
# Use the dynamic linker version to test for libc/glibc.
# Offer chance to install unixODBC.
# Ensure LD_LIBRARY_PATH and LD_RUN_PATH are set before attempting to use
# 	unixODBC commands.
#
# Revision 1.24  1999/09/27 13:19:20  martin
# Fix small bug in handling unixODBC install question.
# Allow installer to replace existing inetd.conf and service
# 	entries instead of forcing new defn.
#
# Revision 1.23  1999/09/16 16:05:20  martin
# Remove duplicate SCO lines.
# Fix bug where LD_LIBRARY_PATH derefererenced.
#
# Revision 1.22  1999/09/14 10:55:07  martin
# Simply add another "Press any key to continue" message so split install
# 	up a bit (and let installers see the console output).
#
# Revision 1.21  1999/09/06 15:02:19  martin
# Add comments on building the unixODBC/OOB Setup library.
#
# Revision 1.20  1999/09/03 14:54:22  martin
# Some OS's find command has to have an action or they return an error.
#
# Revision 1.19  1999/09/03 14:32:36  martin
# Add comment to read the INSTALL file BEFORE installing.
#
# Revision 1.18  1999/09/03 12:21:34  martin
# Add echo messages about running ldconfig and possible warnings output.
# Add support for installing OOB under unixODBC.
#
# Revision 1.17  1999/08/04 12:22:17  martin
# Changed occurrances of can't in cat <<EOF to cannot as some shells
# 	parse the text between cat and EOF.
# Check for find command.
# Change the code at the start which outputs the commands as they are
# 	found to list them across the screen instead of down the screen
# 	to save space and although it to be seen when the terminal scrolls.
# Get the OS release and output a message.
# Add support for SCO Openserver.
# For Linux add a whole host of checks:
# 	Output warning messages for untested kernel versions.
# 	Check the OOB distribution (libc or glibc) matches the c runtime
# 		library in use.
# 	Check for the minimum kernel requirements of libc.
# 	Check we recognise the current runtime libc.
# Fix silly problem testing uid when only set in Linux-specific code.
# Changes to the creation of the shell-startup script. Generate it now
# 	instead of substitution in a template.
#
# Revision 1.16  1999/07/26 15:15:50  martin
# Add "Press any key to continue" messages to allow the screens to be
# 	read one page at a time.
# Change the initial text to explain root requirements better.
# More logical installation order for the OOB client. If not root tell the
# 	installer that entries in ld.so.conf can not be made and should be
# 	done manually. If root, then add the entries BEFORE moving on to
# 	ask whether the service and inetd entries should be added.
# When adding the service and inetd entries add explanation of what they
# 	are for.
# Add messages showing whether the Client and Server were installed OK.
#
# Revision 1.15  1999/07/13 14:24:11  martin
# Fix internal bug ID 373, wrong path added to server/server cd command.
# Fix bug locating server name that already exists - used single quotes
#      around sname preventing env expansion.
#
# Revision 1.14  1999/06/24 08:28:24  martin
# Add rcs history.
#
# Clear the screen
#
if [ -x /usr/bin/clear ]; then
  /usr/bin/clear
fi
#
# Check we are in the dir untarred from the package.
#
if [ ! -x ./install ];then
  echo "You must run the install script from the directory created by"
  echo "untarring the main distribution file."
  exit 1
fi
INSTALLSCRIPTDIR=`pwd`
#
# Check the cwd is writeable as some tests create temporary files in the cwd.
#
if [ ! -w . ];then
  cat <<EOF

The current working directory is not writeable by you. Please correct this
and rerun the install script.

EOF
fi
#
# Output starting screen
#
cat <<EOF
Installation procedure for the Easysoft ODBC-ODBC Bridge

Copyright (c) 1993-2002 Easysoft Limited

Please read the file INSTALL before attempting to install.

EOF
#
# Which echo?
#
if [ -x /bin/echo ];then
  ECHO="/bin/echo"
else
  if [ -x /usr/bin/echo ];then
    ECHO="/usr/bin/echo"
  else
    cat <<EOF
Cannot find the echo command
EOF
  exit 1
  fi
fi
#
# echo interprets backslash chrs by default? POSIX says no.
#
test=`$ECHO "fred\c"`
if [ "$test" = "fred\c" ];then
  oldecho="$ECHO"
  ECHO="$ECHO -e "
  test=`$ECHO "fred\c"`
  if [ "$test" != "fred" ];then
    if [ -x ./echo ];then
      ECHO=`pwd`/echo
    else
      cat <<EOF
echo command ($ECHO) does not interpret backslash characters.
You may see backslash c's when asked questions during this install.
You can safely ignore this except in Linux where you may need to
edit /etc/ld.so.conf to remove extra backslash n's from the lines added
by this script.
EOF
      ECHO="$oldecho"
    fi
  fi
fi
export ECHO			# allow child scripts to see ECHO
#
# Introduction and Licensing
#
./install_intro OOB_intro.txt
if [ $? -ne 0 ];then
  exit $?
fi
#
# Check the command line args
#
#
# Look for optional args
#
if [ $# -gt 0 ];then
  SKIP="$1"
else 
  SKIP=""
fi
SKIPCLIENT=`$ECHO $SKIP | grep 'c' 2>/dev/null`
SKIPSERVER=`$ECHO $SKIP | grep 's' 2>/dev/null`
SKIPLICENSING=`$ECHO $SKIP | grep 'l' 2>/dev/null`
SKIPUNIXODBC=`$ECHO $SKIP | grep 'u' 2>/dev/null`
#
# Check we have the tools we need.
# ================================
#
./install_check_tools
if [ $? -ne 0 ];then
  exit $?
fi
# Need to do tr here as we need to decide what to use for upper->lower
if ( $ECHO "TeSt" | tr '[A-Z]' '[a-z]' 1>/dev/null 2>/dev/null )
then
  $ECHO "tr \c"
  lowctest=`$ECHO "TeSt" | tr '[A-Z]' '[a-z]'`
  if [ "$lowctest" != "test" ];then
    $ECHO
    $ECHO "Do not know how to use tr command to convert uppercase to lowercase"
  else
    LOWERCASE="tr '[A-Z]' '[a-z]'"
  fi
fi
if [ "$LOWERCASE" = "" ];then
  $ECHO "Trying dd"
  lowctest=`$ECHO "TeSt" | dd conv=lcase`
  if [ "$lowctest" != "test" ];then
    $ECHO "Do not know how to use dd command to convert uppercase to lowercase"
  else 
    LOWERCASE="dd conv=lcase"
  fi
fi
if [ "$LOWERCASE" = "" ];then
  $ECHO "Trying sed"
  lowctest=`$ECHO "TeSt" | sed 'y/TES/tes/'`
  if [ "$lowctest" != "test" ];then
    $ECHO "Do not know how to use sed command to convert uppercase to lowercase"
    $ECHO "Cannot continue without a working tr, dd or sed command"
    exit 1
  else
    LOWERCASE="sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'"
  fi
fi
export LOWERCASE
#
# If install_check_tools did not find OS tee but this distrib has a local one
# it will create usetee file.
#
if [ -r ./usetee ];then
  TEE="`pwd`/tee"
else
  TEE="tee"
fi
$ECHO "tee "
export TEE
$ECHO
$ECHO
#
# Set up vars used throughout.
# ============================
#
DEFAULT_PATH="/usr/local"    # default base install path
INST_SUBDIR="easysoft"       # dir under above OOB installed in
INSTINFOFILE="oob_install.info" #where certain install information is recorded
SUPPORT_EMAIL="support@easysoft.com"
export SUPPORT_EMAIL
INSTALLED_UNIXODBC=""        # installed unixODBC DM?
INSTALLED_CLIENT=""          # installed OOB Client?
INSTALLED_SERVER=""          # installed OOB Server?
INSTALLED_COMMON=""          # installed common OOB components?
INSTALLED_LDSO_LINKS=""      # Updated ld.so (linux only)
TARSTDERROUTPUT="$INSTALLSCRIPTDIR/esoobtarerr"
                             # stderr output from any tar extract
INSTALLWARNING="$INSTALLSCRIPTDIR/warnings" # Any warnings during install
#
# See what platform we are on
# ===========================
#
PLATFORM=`uname -s`
platform=`uname -s | $LOWERCASE`
export platform
osrelease=`uname -r`
osversions=`uname -v`
echo "Installation for $platform chosen"
#
# Platform specific differences
# =============================
#
# PIDARG is column is ps output where process ID shown
# PSARGS are the arguments to ps to generate process output that can be
# grepped for inetd's PID
#
# TARGIVESERR should be 1 if the tar on this platform actually works and
# returns an error state (>0) if tar fails. If the tar does not return
# error states then the install will try and examine stderr for errors -
# this is even more problematic as some tars send the -v output to stderr.
#
TARGIVESERR="0"
TARARGS="-xvf"
PIDARG="1"
TESTLINK="-L"
TESTEXISTS="-e"
if [ "$platform" = "irix64" ];then
  PSARGS="-ef"
  PIDARG="2"
  TARGIVESERR="1"
fi
if [ "$platform" = "aix" ];then
  PSARGS="ax"
fi
if [ "$platform" = "hp-ux" ];then
  PSARGS="-ef"
  PIDARG="2"
  TARGIVESERR="1"
fi
if [ "$platform" = "linux" ];then
  TARGIVESERR="1"
  PSARGS="ax"
fi
if [ "$platform" = "sunos" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
  TESTLINK="-h"
fi
if [ "$platform" = "sco_sv" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
fi
if [ "$platform" = "unixware" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
  TARARGS="-xvopf"
fi
if [ "$platform" = "unix_sv" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
fi
if [ "$platform" = "freebsd" ];then
  PSARGS="ax"
  TESTLINK="-h"
fi
if [ "$platform" = "sinix-n" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
  TESTLINK="-h"
fi
if [ "$platform" = "osf1" ];then
  TARGIVESERR="1"
  PSARGS="-ef"
  PIDARG="2"
fi
if [ "$platform" = "darwin" ];then
  TARGIVESERR="1"		# sometimes!!
  PSARGS="ax"
  PIDARG="1"
fi
export TESTEXISTS		# make TESTEXISTS available to child scripts
export TESTLINK			# make TESTLINK available to child scripts
export PIDARG
export PSARGS
#
# Platform specific checks
# ========================
#
# Linux - see what the highest version of libc installed is.
#
if [ "$platform" = "linux" ];then
  ./install_check_linux 'ODBC-ODBC Bridge' 1
  if [ $? != 0 ];then
    exit $?
  fi
elif [ "$platform" = "sunos" ]; then
  ./install_check_sunos 'ODBC-ODBC Bridge'
  if [ $? != 0 ];then
    exit $?
  fi
fi
#
# Check the package
# =================
#
# Check the tar file(s) exist (there may be more than one)
#  e.g. for multiple sub-packages
# Check the md5sum/sum is correct.
# 
$ECHO "Press the return key to continue"
read press
$ECHO
$ECHO "Checking your package is OK..."
TARPATTERN="*.tar"
TARFILE_LIST=`$ECHO $TARPATTERN`
exist=`$ECHO $TARFILE_LIST`
#
# If the shell did not expand *.tar then there can't be any matching
# tar files in this dir.
#
if [ "$exist" = "$TARPATTERN" ]; then
  $ECHO "Cannot find any tar file packages matching \"$TARPATTERN\" in"
  $ECHO "the current directory. Are you sure you are running the install"
  $ECHO "script in the same directory the first tar file was unpacked to?"
  exit 1
fi
#
# Find out how many tar files we have and check each one.
#
TARFILES=`$ECHO $TARFILE_LIST | wc -w | awk '{print $1}'`
$ECHO "Found $TARFILES package(s)"
for TARFILE in $TARFILE_LIST
do
  $ECHO "Checking $TARFILE"
  if [ ! -r $TARFILE ];then
    $ECHO "Cannot find readable $TARFILE file"
    exit 1
  fi
  #
  # Try checking the tar file with md5sum.
  #
  checked=""
  if [ -r $TARFILE.md5sum ];then
    sh -c md5sum < ./install 2> /dev/null 1> /dev/null 
    if [ $? -eq 0 ];then
	HASMD5SUM="y"
    fi
    if [ "HASMD5SUM" = "y" ] 
    then    
      check=`md5sum $TARFILE | awk '{print $1}'`
      check2=`cat $TARFILE.md5sum`
      if [ "$check" = "$check2" ];then
  	checked="ok"
      else
  	checked="fail"
      fi
    else
      $ECHO "Can't find md5sum on this machine - ignoring md5 checksum"
    fi
  else
    $ECHO "$TARFILE.md5sum not found - ignoring."
  fi
  #
  # Try checking the tar file with sum.
  #
  if [ "$checked" = "" ];then
    if  [ -r $TARFILE.sum ];then
      if ( $ECHO "test" | sum 2> /dev/null 1> /dev/null )
      then
  	check=`sum $TARFILE | awk '{print $1}'`
  	check2=`cat $TARFILE.sum`
  	if [ "$check" = "$check2" ];then
  	  checked="ok"
  	else
  	  checked="fail"
  	fi
      else
  	$ECHO "Can't find sum on this machine"
      fi
    else
      $ECHO "$TARFILE.sum not found - ignoring,"
    fi
  fi
done
#
# Tar files not checksummed
# =========================
#
# If we failed to check a tar file then give the installer a chance to
# pull out of the installation.
#
if [ "$checked" = "" ];then
  $ECHO "Tarred packages not checked - can't find md5sum or sum."
  $ECHO "This package comes with a md5 message digest and a checksum."
  $ECHO "The installation was unable to check the package due to either"
  $ECHO "[1] failed to locate md5sum or sum."
  $ECHO "[2] failed to locate the md5 or checksum package files."
  $ECHO "It is not absolutely necessary to check your package in this way"
  $ECHO "and it is usually safe to continue."
  $ECHO
  $ECHO "Do you want to continue? (y/n) [n]: \c"
  answer="haha"
  while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
  do
    read answer
    if [ "$answer" = "" ];then
      answer="n"
    fi
    if [ "$answer" != "y" ];then
      $ECHO "Installation terminated"
      exit 99
    fi
  done
fi
$ECHO "Package check - OK"
$ECHO
$ECHO "Press the return key to continue"
read press
#
# Check for root
# ==============
#
./install_check_root 'ODBC-ODBC Bridge' OOB_check_root.txt 1
if [ $? -ne 0 ];then
  exit $?
fi
#
#  Install Path
#  ============
#
cat <<EOF

You need to enter a location for the Easysoft ODBC-ODBC Bridge. You
should specify an existing directory under which directories called
"$INST_SUBDIR/oob", "$INST_SUBDIR/lib", "$INST_SUBDIR/license",
"$INST_SUBDIR/etc". "$INST_SUBDIR/bin" and possibly "$INST_SUBDIR/unixODBC" 
will be created.
You need write permission to the specified directory. If the last directory
in the path you specify does not exist the installation will ask whether
you would like it to be created.

Just hit <enter> for the defaults.
EOF

#
# Request and create installation path
# ====================================
#
path=""
while [ "$path" = "" ]
do
  $ECHO "Enter a base install directory (q=quit) [ $DEFAULT_PATH ]: \c"
  read path
  if [ "$path" = "q" ];then
    $ECHO "Installation aborted at user request"
    exit 99
  fi
  if [ "$path" = "" ];then
    path="$DEFAULT_PATH"
  fi
  #
  # If the stem install dir (/usr/local default) does not exist create it.
  #
  if [ ! -d "$path" ]; then
    $ECHO "$path does not exist"
    $ECHO "Do you want to attempt to create it (y/n) [y]: \c"
    answer="hoho"
    while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
    do
      read answer
      if [ "$answer" = "" ];then
        answer="y"
      fi
      if [ "$answer" = "y" ];then
        mkdir $path
	if [ $? -ne 0 ]
	then
          $ECHO "Failed to create $path"
	  path=""
	fi
      else
        path=""
      fi
    done
  elif [ ! -w "$path" ]; then
    $ECHO "$path is not writeable"
    path=""
  fi
done
$ECHO
#
# We now make the <install_path>/$INST_SUBDIR tree (e.g. /usr/local/easysoft)
# INST_SUBDIR may have more than one dir in it.
#
$ECHO "Making install dir \c"
echo "$path/$INST_SUBDIR" | sed 's,//,/,g'
flds=`echo "$INST_SUBDIR" | sed 's,/, ,g'`
base=`echo "$INST_SUBDIR" | awk -F/ '{print $NF}'`
stem=""
for dir in $flds
do
  xpath=`echo $path/$stem/$dir | sed 's,//,/,g'`
  if [ -d "$path/$stem/$dir" ];then
    $ECHO "$xpath already exists."
    $ECHO
    if [ "$dir" = "$base" ];then
      SQIS=""
      if [ -d "$path/$stem/$dir/sqi" ];then
        for sqi in tetra systemz enguard
        do
          if [ -d "$path/$stem/$dir/sqi/$sqi" ];then
            SQIS="$SQIS $sqi "
          fi
        done
      fi
      cat <<EOF
If you are reinstalling then it is wise to delete
$path/easysoft/oob first
(as this will tell you if files are in use).

If you are upgrading from a previous beta then Easysoft strongly
recommend you remove the previous beta first.

EOF
      if [ "$SQIS" != "" ];then
        cat <<EOF
**WARNING**

It appears you have other Easysoft products installed. In particular this
install found

$SQIS

There have been some incompatabilities between some versions of OOB and
some sqi drivers. Please make sure you got this OOB from the same directory
on our FTP site as your installed SQI driver or check with Easysoft support
before continuing.

EOF
      fi
      $ECHO "Continue with install? (y/n) [y]: \c"
      answer="haha"
      while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
      do
        read answer
        if [ "$answer" = "" ];then
          answer="y"
        fi
        if [ "$answer" != "y" ];then
          $ECHO "Installation terminated"
          exit 99
        fi
      done
    fi
  else
    if ( mkdir $xpath )
    then
      $ECHO "$xpath created"
    else
      $ECHO "Failed to create $xpath"
      exit 1
    fi
  fi
  stem="$stem/$dir"
done
#
#  If not installed in the default place provide a symbolic link from the
#  default to the actual or shared object runpaths won't work.
#
if [ "$path" != "$DEFAULT_PATH" ];then
cat <<EOF

WARNING:
You have not chosen the default path for installing the Easysoft ODBC-ODBC
Bridge. For the built-in shared object run paths and licensing to work the
installation needs to link $DEFAULT_PATH/$INST_SUBDIR to $path/$INST_SUBDIR.

EOF
  instsymlinkexists="n"
  answer="hoho"
  if [ "$TESTEXISTS" "$DEFAULT_PATH/$INST_SUBDIR" ];then
    $ECHO "but $DEFAULT_PATH/$INST_SUBDIR already exists"
    if [ "$TESTLINK" "$DEFAULT_PATH/$INST_SUBDIR" ];then
      instsymlinkexists="y"
      $ECHO "and is a symbolic link."
      $ECHO "Do you want to replace the symbolic link"
      $ECHO "$DEFAULT_PATH/$INST_SUBDIR ? (y/n) [y]: \c"
      while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
      do
  	read answer
  	if [ "$answer" = "" ];then
  	  answer="y"
  	fi
      done
    else
      $ECHO "and is not a symbolic link."
      cat <<EOF
Please see the INSTALL file for information on how this may be corrected
before continuing with this installation.
EOF
    fi
  else
    if [ ! "$TESTEXISTS" /usr/local ]; then
      if ( mkdir /usr/local )
      then
        $ECHO "/usr/local created"
      else
        $ECHO "Failed to create /usr/local"
      fi
    fi
    answer="y"
  fi
  if [ "$answer" = "y" ];then
    #
    # would like to use -sf (force) but some platforms do not have -f
    # so move existing link out of the way
    #
    if [ "$instsymlinkexists" = "y" ];then
      mv $DEFAULT_PATH/$INST_SUBDIR $DEFAULT_PATH/${INST_SUBDIR}_before_easysoft
    fi
    ln -s $path/$INST_SUBDIR $DEFAULT_PATH/$INST_SUBDIR
    if [ $? -ne 0 ]; then
      $ECHO "**WARNING** Failed to create easysoft symbolic link" | "$TEE" -a "$INSTALLWARNING"
      $ECHO "See INSTALL file for information on how this may be corrected"
    fi
  fi
fi
#
# Record the version of OOB installed
# Note this depends on the directory name.
#
VERSION=`pwd | sed 's|.*\([0-9]\{1,2\}\)\.\([0-9]\{1,2\}\)\.\([0-9]\{1,2\}\)\.\([0-9]\{1,2\}\).*|\1.\2.\3.\4|'`
$ECHO "product: odbc-odbc-bridge" >> $path/$INST_SUBDIR/$INSTINFOFILE
$ECHO "version: $VERSION" >> $path/$INST_SUBDIR/$INSTINFOFILE
$ECHO "date: \c" >> $path/$INST_SUBDIR/$INSTINFOFILE
date 2>/dev/null >> $path/$INST_SUBDIR/$INSTINFOFILE
#
# Install unixODBC DM
# ===================
#
# Give the installer a chance to install unixODBC
#
if [ "$SKIPUNIXODBC" != "" ];then
  $ECHO 
  $ECHO "Skipping unixODBC installation as requested"
  $ECHO
else
  $ECHO "Press the return key to continue"
  read press
  ./uodbc install unixodbc $path/$INST_SUBDIR 'ODBC-ODBC Bridge' OOB 0 0
  answer=$?
  if [ $answer -gt 1 ];then
    $ECHO "Failed to install/locate unixODBC, uodbc returns $answer"
  else
    if [ $answer -eq 1 ];then
      INSTALLED_UNIXODBC="y"	# unixODBC DM was installed
    elif [ "$TESTEXISTS" ./uodbc_tmp ];then
      INSTALLED_UNIXODBC="n"      # it exists but we did not install it
    fi
  fi
fi
#
# Install OOB Common
# ==================
#
# Unpack the common tar file
#
if [ \( "$SKIPCLIENT" != "" \) -a \( "$SKIPSERVER" != "" \) ];then
  cat <<EOF
Skipping common parts of OOB install because neither the server
nor the client is being installed.
EOF
else
  cwd=`pwd`
  cd $path/$INST_SUBDIR
  $ECHO
  $ECHO "Unpacking Common parts of the ODBC ODBC Bridge distribution"
  $ECHO "Press the return key to continue"
  read press
  > "$TARSTDERROUTPUT"
  if [ "$TARGIVESERR" = "1" ];then
    tar "$TARARGS" $cwd/all*.tar
  else
    tar "$TARARGS" $cwd/all*.tar 2>"$TARSTDERROUTPUT"
  fi
  if [ $? -ne 0 ];then
    $ECHO
    $ECHO "**WARNING**: Errors occurred during untar (all) operation" | "$TEE" -a "$INSTALLWARNING"
    $ECHO "Please check the following tar output before continuing:"
    $ECHO "****************************************"
    cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
    $ECHO "****************************************"
  else
    output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize"`
    if [ "$output" != "" ];then
      $ECHO
      $ECHO "**WARNING**: tar (all) returned successful but output text to stderr" | "$TEE" -a "$INSTALLWARNING"
      $ECHO "This is suspicious and should be investigated."
      $ECHO "Please check the following tar output before continuing:"
      $ECHO "****************************************"
      cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
      $ECHO "****************************************"
    fi
  fi
  > "$TARSTDERROUTPUT"
  
  INSTALLED_COMMON="y"
  cd "$cwd"
fi
#
# Install Versioned Common files
# ==============================
#
./install_versioned "$path/$INST_SUBDIR"
if [ $? -ne 0 ];then
  $ECHO "WARNING Failed to install all versioned files"  | "$TEE" -a "$INSTALLWARNING"
  $ECHO "Please mail Easysoft support at $SUPPORT_EMAIL"
fi
#
# Install the OOB Client
# ======================
#
if [ "$SKIPCLIENT" != "" ];then
  $ECHO
  $ECHO "Skipping OOB client installation as requested"
  $ECHO
else
  $ECHO
  cat <<EOF
Easysoft OOB client
===================

You can now install the Client side of the ODBC-ODBC Bridge. You need to
install the Client if you want to access remote ODBC Drivers from applications
running on this machine e.g. A Perl DBI script on this machine accessing
MS SQLServer on a remote NT machine.

NOTE:
You will need to install the OOB Server on remote machine(s) where an ODBC
driver for your database is located. The OOB client is not a native ODBC
driver for any particular database, it is an ODBC bridge.

EOF
  answer="hoho"
  $ECHO "Install ODBC-ODBC Bridge Client (y/n) [y]: \c"
  while [ "$answer" != "" -a "$answer" != "y" -a "$answer" != "n" ]
  do
    read answer
    if [ "$answer" = "" ];then
      answer="y"
    fi
    if [ "$answer" = "y" ];then
      #
      # Unpack the Client tar file
      #
      cwd=`pwd`
      cd $path/$INST_SUBDIR
      $ECHO
      $ECHO "Unpacking Client parts of the ODBC-ODBC Bridge distribution"
      $ECHO "Press the return key to continue"
      read press
      > "$TARSTDERROUTPUT"
      if [ "$TARGIVESERR" = "1" ];then
  	tar "$TARARGS" $cwd/client*.tar
      else
  	tar "$TARARGS" $cwd/client*.tar 2>"$TARSTDERROUTPUT"
      fi
      if [ $? -ne 0 ];then
  	$ECHO
  	$ECHO "**WARNING**: Errors occurred during untar (client) operation" | "$TEE" -a "$INSTALLWARNING"
  	$ECHO "Please check the following tar output before continuing:"
  	$ECHO "****************************************"
  	cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
  	$ECHO "****************************************"
      else
  	output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize"`
  	if [ "$output" != "" ];then
  	  $ECHO
  	  $ECHO "**WARNING**: tar (client) returned successful but output text to stderr" | "$TEE" -a "$INSTALLWARNING"
  	  $ECHO "This is suspicious and should be investigated."
  	  $ECHO "Please check the following tar output before continuing:"
  	  $ECHO "****************************************"
  	  cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
  	  $ECHO "****************************************"
  	fi
      fi
      > "$TARSTDERROUTPUT"
      INSTALLED_CLIENT="y"
      $ECHO
      cd $cwd
    fi
  done
fi # end of OOB client
#
$ECHO "Press the return key to continue"
read press
#
# Set LD_LIBRARY_PATH and LD_RUN_PATH so we can pick up unixODBC libs.
#
LDPATHLIBDIRS="$path/$INST_SUBDIR/lib"
if [ "$INSTALLED_CLIENT" != "" ];then
  LDPATHLIBDIRS="$LDPATHLIBDIRS:$path/$INST_SUBDIR/oob/client"
fi
if [ "$INSTALLED_UNIXODBC" != "" ];then
  LDPATHLIBDIRS="$LDPATHLIBDIRS:$path/$INST_SUBDIR/unixODBC/lib"
fi
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LDPATHLIBDIRS"
export LD_LIBRARY_PATH
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$LDPATHLIBDIRS"
export DYLD_LIBRARY_PATH
LD_RUN_PATH="$LD_RUN_PATH:$LDPATHLIBDIRS"
export LD_RUN_PATH
SHLIB_PATH="$SHLIB_PATH:$LDPATHLIBDIRS"
export SHLIB_PATH
LIBPATH="$LIBPATH:$LDPATHLIBDIRS"
export LIBPATH
LDLIBDIRS=`echo $LDPATHLIBDIRS | sed 's/:/ /g'`
#
# Install ld.so paths
# ===================
#
# To finish off the Client/unixODBC/Common install for Linux, we need to add
# entries to the /etc/ld.so.conf file for the dynamic linker. We need to be
# root for that. In all cases we at least need to install the oob/lib dir.
#
./install_linkpaths 'ODBC-ODBC Bridge' $LDLIBDIRS
if [ $? -ne 0 ];then
  $ECHO "WARNING: Failed to install all link paths" | "$TEE" -a "$INSTALLWARNING"
fi
#
# Install esld.so.conf entries
#
./install_paths "$path/$INST_SUBDIR" $LDLIBDIRS
sts=$?
if [ $sts -ne 0 ];then
  $ECHO "WARNING: esld.so.conf file not updated successfully" | "$TEE" -a "$INSTALLWARNING"
  $ECHO "WARNING: install_paths returned $sts" | "$TEE" -a "$INSTALLWARNING"
fi
if [ "$INSTALLED_CLIENT" = "y" ];then
  $ECHO
  $ECHO "** The OOB Client has been installed successfully **"
  $ECHO
fi
$ECHO "Press the return key to continue"
read press
#
# Install OOB Client under unixODBC DM
# ====================================
#
if [ \( "$INSTALLED_CLIENT" = "y" \) -a \( "$INSTALLED_UNIXODBC" != "" \) ];then
cat <<EOF

You can install OOB for the unixODBC (http://www.unixodbc.org) driver manager
now if you would like. You do not have to do this as OOB works fine without
a driver manager. However, if you have already installed unixODBC then
you probably want to do this.

You will probably have to be the root user to do this.

If you choose this option you should look at the unixODBC subdirectory
of the OOB (e.g. /usr/local/easysoft/oob/unixODBC) as the setup library
required by unixODBC's GUI ODBCConfig utility to create OOB DSNs may have
to be built for your platform. If you choose not to do this you can still
define OOB DSNs by editing the odbc.ini files.

EOF
  if [ "$INSTALLED_UNIXODBC" = "y" ];then
    defaultanswer="y"
  else
    defaultanswer="n"
  fi
  answer="hoho"
  while [ "$answer" != "" -a "$answer" != "y" -a "$answer" != "n" ]
  do
    $ECHO "Install OOB into unixODBC (y/n) [$defaultanswer]: \c"
    read answer
    if [ "$answer" = "" ];then
      answer="$defaultanswer"
    fi
  done
  if [ "$answer" = "y" ];then
    #
    # NB. The template file must be < 14 chrs as there is a bug in unixODBC
    # for HP-UX that restricts the file to FILENAME_MAX which is 14. 
    #
    TEMPLATE="oob.tmpl"
    > $TEMPLATE
    $ECHO "[OOB]" >> $TEMPLATE
    $ECHO "Description = Easysoft ODBC-ODBC Bridge" >> $TEMPLATE
    oobso=`find $path/$INST_SUBDIR/oob/client -name "libesoobclient*.*" -print | head -1`
    $ECHO "Driver = $oobso" >> $TEMPLATE
    if [ "$oobso" = "" ];then
      $ECHO "WARNING:"
      $ECHO "Could not locate OOB client ODBC driver shared object" | "$TEE" -a "$INSTALLWARNING"
      $ECHO "Please report this to $SUPPORT_EMAIL then check your"
      $ECHO "/etc/odbcinst.ini file after this installation"
      $ECHO "(in particular the Driver attribute)."
      $ECHO "Press the return key to continue"
      read press
    fi
    oobsetupso=`find $path/$INST_SUBDIR/oob/client -name "libesoobsetup.*" -print`
    $ECHO "Setup = $oobsetupso" >> $TEMPLATE
    ./uodbc driver $TEMPLATE 'ODBC-ODBC Bridge' OOB 
    if [ $? -ne 0 ]; then
      $ECHO "** Failed to install OOB for unixODBC **"
    else
      if [ "$TESTEXISTS" dsn_template ];then
        ./uodbc dsn dsn_template 'ODBC-ODBC Bridge' OOB
      fi # dsn_template exists
    fi # successfully installed OOB under unixODBC
  fi # install OOB under unixODBC
  $ECHO "Press the return key to continue"
  read press
fi
#
# Install the OOB Server (files)
# ==============================
#
if [ "$SKIPSERVER" != "" ];then
  $ECHO
  $ECHO "Skipping OOB Server installation as requested"
  $ECHO
else
  cat <<EOF
  
You can now install the Server side of the ODBC-ODBC Bridge. You need to
install the Server if you want to access ODBC drivers on this machine
from other remote machines (where you install the OOB Client). The
OOB Server is linked against the libodbc shared object so you must either:

[1] Install the unixODBC Driver Manager (which provides libodbc) and then
    tell the driver manager about your ODBC Drivers (preferred method) OR
[2] Ensure that the ODBC driver you want to use is available as libodbc.so
    (amend extension appropriate for platform). You can do this by simply
    renaming your ODBC driver.

EOF
  answer="hoho"
  $ECHO "Install ODBC-ODBC Bridge Server (y/n) [y]: \c"
  while [ "$answer" != "" -a "$answer" != "y" -a "$answer" != "n" ]
  do
    read answer
    if [ "$answer" = "" ];then
      answer="y"
    fi
    if [ "$answer" = "y" ];then
      #
      # Unpack the Server tar file
      #
      cwd=`pwd`
      cd $path/$INST_SUBDIR
      $ECHO
      $ECHO "Unpacking Server parts of the ODBC-ODBC Bridge distribution"
      $ECHO "Press the return key to continue"
      read press
      > "$TARSTDERROUTPUT"
      if [ "$TARGIVESERR" = "1" ];then
  	tar "$TARARGS" $cwd/server*.tar
      else
  	tar "$TARARGS" $cwd/server*.tar 2>"$TARSTDERROUTPUT"
      fi
      if [ $? -ne 0 ];then
  	$ECHO
  	$ECHO "**WARNING**: Errors occurred during untar (server) operation" | "$TEE" -a "$INSTALLWARNING"
  	$ECHO "Please check the following tar output before continuing:"
  	$ECHO "****************************************"
  	cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
  	$ECHO "****************************************"
      else
  	output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize"`
  	if [ "$output" != "" ];then
  	  $ECHO
  	  $ECHO "**WARNING**: tar (server) returned successful but output text to stderr" | "$TEE" -a "$INSTALLWARNING"
  	  $ECHO "This is suspicious and should be investigated."
  	  $ECHO "Please check the following tar output before continuing:"
  	  $ECHO "****************************************"
  	  cat "$TARSTDERROUTPUT" | "$TEE" -a "$INSTALLWARNING"
  	  $ECHO "****************************************"
  	fi
      fi
      > "$TARSTDERROUTPUT"
      INSTALLED_SERVER="y"
      $ECHO
      cd $cwd
    fi
  done
fi # end of server
#
$ECHO "Press the return key to continue"
read press
#
#  Exit now if server not installed
#
if [ "$INSTALLED_SERVER" != "y" ];then
  if [ "$TESTEXISTS" "$INSTALLWARNING" ];then
    output=`cat "$INSTALLWARNING" 2>/dev/null`
    if [ "$output" != "" ];then
      cat <<EOF
*******************************************************************
Warnings were output during this installation which may be found in the file
$INSTALLWARNING.
Please review these warnings as they could mean some part of this distribution
was not installed correctly. If you are unsure send a copy of the
$INSTALLWARNING file
to $SUPPORT_EMAIL along with details of the platform, operating system 
and OOB distribution.
*******************************************************************
EOF
      $ECHO "Press the return key to continue"
      read press
    fi
  else
    $ECHO "Installation completed successfully"
  fi
  ./postinstall
  exit 0
fi
#
# Check for an existing license dir and file. If one does not exist make
# the license dir and copy a blank license file in to it.
#
if [ "$SKIPLICENSING" != "" ];then
  $ECHO
  $ECHO "Skipping licensing as requested"
  $ECHO
else
  cat <<EOF
The OOB Server requires a license key to operate. You can obtain
trial or fully purchased keys during this installation or afterwards
from Easysoft.

EOF
  ./install_license 'OOB Server' $path/easysoft
fi
#
#
# root-specific install
# =====================
#
uid=`id | awk '{print $1}' | awk -F= '{print $2}' | awk -F\( '{print $1}'`
$ECHO 
$ECHO "You must be root to continue on with this script and complete the OOB"
$ECHO "Server installation which adds entries to your inetd and service files."
if [ "$uid" != "0" ];then
  cat <<EOF
...and you are not root

Press the return key and the rest of this installation will be aborted.
Then see the installation documentation for how root can complete
the OOB server installation.
EOF
  read line
  exit 2
fi
$ECHO
$ECHO "Do you wish to install the services and inetd entries? (y/n) [y]: \c"
answer="haha"
while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
do
  read answer
  if [ "$answer" = "" ]; then
    answer="y"
  fi
  installservice="$answer"
done
#
#  Install the service
#
if [ "$installservice" = "y" ];then
  cwd=`pwd`
  ./install_service 'OOB Server' $path/easysoft
  cd $cwd
  $ECHO "Press the return key to continue"
  read press
fi
#
# Create the shell startup script
#
cd $path/easysoft/oob
sout="server/install/shell_startup.conf"
> $sout
$ECHO "#!$shellpath" >> $sout
#
# wanted to put the following in cat >> file << EOF but some vendors Bourne
# shells interpret the comment characters.
#
$ECHO "#" >> $sout
$ECHO "# This is the OOB Server startup script run by inetd." >> $sout
$ECHO "#" >> $sout
$ECHO "# You only need to set up the OOB Server on this machine if you want" >> $sout
$ECHO "# to gain access to ODBC databases on this machine through the OOB" >> $sout
$ECHO "# client on a remote machine." >> $sout
$ECHO "#" >> $sout
$ECHO "# The OOB Server is dynamically linked with libodbc.<shared_extension>" >> $sout
$ECHO "# You need to rename your ODBC driver or driver manager to" >> $sout
$ECHO "# libodbc.<shared_extension> and change the path in the next line" >> $sout
$ECHO "# to point at the directory where your ODBC driver or driver manager" >> $sout
$ECHO "# is located." >> $sout
$ECHO "# <shared_extension> is .so, .a or .sl depending on your platform." >> $sout
$ECHO "#" >> $sout
$ECHO 'ldpaths=`cat ' "$path/easysoft/etc/es.ld.so.conf" '`' >> $sout
$ECHO "ldpaths=\`echo " '$ldpaths' "| sed 's/ /:/g'\`" >> $sout
$ECHO 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ldpaths' >> $sout
$ECHO 'export LD_LIBRARY_PATH' >> $sout
$ECHO 'DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ldpaths' >> $sout
$ECHO 'export DYLD_LIBRARY_PATH' >> $sout
$ECHO 'SHLIB_PATH=$SHLIB_PATH:$ldpaths' >> $sout
$ECHO 'export SHLIB_PATH' >> $sout
$ECHO 'LIBPATH=$LIBPATH:$ldpaths' >> $sout
$ECHO 'export LIBPATH' >> $sout
$ECHO "cd $path/easysoft/oob/server" >> $sout
$ECHO './esoobserver inetd' >> $sout
cp server/install/shell_startup.conf server/server
chmod ugo+x server/server
#
cd $cwd
$ECHO
if [ "$TESTEXISTS" "$INSTALLWARNING" ];then
  output=`cat "$INSTALLWARNING" 2>/dev/null`
  if [ "$output" != "" ];then
    cat <<EOF
*******************************************************************
Warnings were output during this installation which may be found in the file
$INSTALLWARNING.
Please review these warnings as they could mean some part of this distribution
was not installed correctly. If you are unsure send a copy of the
$INSTALLWARNING file
to $SUPPORT_EMAIL along with details of the platform, operating system
and OOB distribution.
*******************************************************************
EOF
    $ECHO "Press the return key to continue"
    read press
  fi
else
  $ECHO "** The OOB Server has been installed successfully **"
fi
./postinstall
