#!/bin/sh
#
# Copyright (c) 1993-2007 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 1234 2024-03-22 10:06:53Z nick $
#
# 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 (OOB)

Copyright (c) 1993-2014 Easysoft Limited

Please read the file INSTALL.txt 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
#
# 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`
#
# Introduction and Licensing
#
if [ "$SKIPLICENSING" != "" ];then
  ./install_intro OOB_intro.txt skip
else
  ./install_intro OOB_intro.txt
fi
if [ $? -ne 0 ];then
  exit $?
fi
#
# 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?
UNIXODBC_EXISTS=""           # existing unixODBC found - not installed
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"
TARV2STDERR="0"
TARARGS="-xf"
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"
  TARV2STDERR="1"
fi
if [ "$platform" = "osf1" ];then
  TARGIVESERR="1"
  PSARGS="-ef"
  PIDARG="2"
fi
if [ "$platform" = "darwin" ];then
  TARGIVESERR="1"		# sometimes!!
  PSARGS="ax"
  PIDARG="1"
fi
if [ "$platform" = "openunix" ];then
  PSARGS="-ef"
  PIDARG="2"
  TESTEXISTS="-r"
  TARARGS="-xvopf"
fi
if [ "$platform" = "interix" ];then
  TARGIVESERR="1"
  PSARGS="ax"
fi
export TESTEXISTS		# make TESTEXISTS available to child scripts
export TESTLINK			# make TESTLINK available to child scripts
export PIDARG
export PSARGS
export TARARGS
#
# Init
# ====
#
./install_init 'ODBC-ODBC Bridge'
if [ $? -ne 0 ];then
  exit $?
fi
#
# 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"
      $ECHO
    fi
  else
    #$ECHO "$TARFILE.md5sum not found - ignoring."
    $ECHO
  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
  answer="haha"
  while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
  do
    $ECHO "Do you want to continue? (y/n) [n]: \c"
    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 the return key 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" -a ! -w "$path/$INST_SUBDIR" ]; then
    $ECHO "$path or $path/$INST_SUBDIR is not writeable"
    path=""
  fi
done
$ECHO
#
# Upgrades
#
if [ "$TESTEXISTS" "$path/easysoft/license/licenses" ];then
  cat <<EOF

**WARNING**

If you are upgrading the OOB Server from a previous major or minor
version (e.g. you have OOB 1.4 installed and are installing OOB 1.5)
then you will need to obtain a new OOB Server license.  Customers with
support/maintenance agreements can do this by contacting
license@easysoft.com.

If you have not got a support/maintenance contract then abort the
upgrade now and contact sales@easysoft.com.

EOF
  answer="haha"
  while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
  do
    $ECHO "Do you want to continue? (y/n) [y]: \c"
    read answer
    if [ "$answer" = "" ];then
      answer="y"
    fi
    if [ "$answer" = "n" ];then
      $ECHO "Installation aborted at user request"
      exit 99
    fi
  done
  $ECHO
fi
#
# 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).

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" = "n" ];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
#
if [ ! "$TESTEXISTS" "$path/$INST_SUBDIR/oob" ];then
  mkdir $path/$INST_SUBDIR/oob
fi
$ECHO "product: odbc-odbc-bridge" >> $path/$INST_SUBDIR/oob/$INSTINFOFILE
$ECHO "version: $VERSION" >> $path/$INST_SUBDIR/oob/$INSTINFOFILE
$ECHO "date: \c" >> $path/$INST_SUBDIR/oob/$INSTINFOFILE
date 2>/dev/null >> $path/$INST_SUBDIR/oob/$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 1 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
      UNIXODBC_EXISTS="y"
    elif [ "$TESTEXISTS" ./uodbc_tmp ];then
      INSTALLED_UNIXODBC="n"      # it exists but we did not install it
      UNIXODBC_EXISTS="y"
    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
  sts=$?
  if [ "$TARV2STDERR"  = "1" ];then
    cat "$TARSTDERROUTPUT";
  fi
  tarerr="n"
  if [ $sts -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 "****************************************"
    tarerr="y"
  else
    output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize" | grep -v "^x.*$"`
    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 "****************************************"
      tarerr="y"
    fi
  fi
  if [ "$tarerr" = "y" ];then
    answer="hoho"
    while [ "$answer" != "y" -a "$answer" != "n" ]
    do
      $ECHO "Warnings were output above. Continue? (y/n) [n]: \c"
      read answer
      if [ "$answer" = "" ];then
	answer="n"
      fi
      if [ "$answer" = "n" ];then
	$ECHO "Installation terminated"
        exit 99
      fi
    done
  fi
  > "$TARSTDERROUTPUT"
  
  INSTALLED_COMMON="y"
  cd "$cwd"
fi
#
# Install Versioned Common files
# ==============================
#
./install_versioned "$path/$INST_SUBDIR"
if [ $? -ne 0 ];then
  $ECHO
  $ECHO "**ERROR** Failed to install all versioned files."  | "$TEE" -a "$INSTALLWARNING"
cat <<EOF
Please examine the above errors to determine the problem, fix and reinstall
or mail Easysoft support at $SUPPORT_EMAIL for assistance.

EOF
  answer="haha"
  while [ "$answer" != "y" -a "$answer" != "n" ]
  do
    $ECHO "Quit install (y/n) [y]: \c"
    read answer
    if [ "$answer" = "" ];then
      answer="y"
    fi
    if [ "$answer" = "y" ];then
      $ECHO "Installation terminated"
      exit 99
    fi
  done
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 SQL Server on a remote MS Windows 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"
  while [ "$answer" != "" -a "$answer" != "y" -a "$answer" != "n" ]
  do
    $ECHO "Install ODBC-ODBC Bridge Client (y/n) [y]: \c"
    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"
      > "$TARSTDERROUTPUT"
      if [ "$TARGIVESERR" = "1" ];then
  	tar "$TARARGS" $cwd/client*.tar
      else
  	tar "$TARARGS" $cwd/client*.tar 2>"$TARSTDERROUTPUT"
      fi
      sts=$?
      if [ "$TARV2STDERR"  = "1" ];then
	  cat "$TARSTDERROUTPUT";
      fi
      tarerr="n"
      if [ $sts -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 "****************************************"
	tarerr="y"
      else
  	output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize" | grep -v "^x.*$"`
  	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 "****************************************"
	  tarerr="y"
  	fi
      fi
      if [ "$tarerr" = "y" ];then
	answer="hoho"
	while [ "$answer" != "y" -a "$answer" != "n" ]
	do
	  $ECHO "Warnings were output above. Continue? (y/n) [n]: \c"
	  read answer
	  if [ "$answer" = "" ];then
	    answer="n"
	  fi
	  if [ "$answer" = "n" ];then
	    $ECHO "Installation terminated"
	    exit 99
	  fi
	done
      fi
      > "$TARSTDERROUTPUT"
      INSTALLED_CLIENT="y"
      $ECHO
      cd $cwd
      ####if [ "$tarerr" != "y" ];then
	####$ECHO "Press the return key to continue"
	####read press
      ####fi
    fi
  done
fi # end of OOB client
#
#
# 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
#
# Install OOB Client under unixODBC DM
# ====================================
#
if [ \( "$INSTALLED_CLIENT" = "y" \) -a \( "$UNIXODBC_EXISTS" = "y" \) ];then
cat <<EOF

You have the unixODBC (http://www.unixodbc.org) Driver Manager.  You
need to install the OOB Client ODBC driver into the unixODBC Driver
Manager to make it available to all your ODBC applications.

This script will create an OOB Driver entry and depending on the platform
it may also create an OOB_r driver entry. The OOB_r driver is a thread-safe
driver you can use with programs built threaded.
EOF
uid=`id | awk '{print $1}' | awk -F= '{print $2}' | awk -F\( '{print $1}'`
if [ "$uid" != "0" ];then
cat <<EOF 

You will probably have to be the root user to do this as unixODBC's
odbcinst command appends drivers to an odbcinst.ini file which is
owned by root.
EOF
fi
  if [ \( "$INSTALLED_UNIXODBC" = "y" \) -o \( "$UNIXODBC_EXISTS" = "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. 
    #
    cat <<EOF
Searching $path/$INST_SUBDIR/oob/client
for installed OOB ODBC drivers
EOF
    oobsos=`find $path/$INST_SUBDIR/oob/client -type f -name "libesoobclient*.*" -print`
    oobsetupso=`find $path/$INST_SUBDIR/oob/client -type f -name "libesoobsetup.*" -print`
    if [ "$oobsos" = "" ];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
    else
      $ECHO "Found:"
      $ECHO "$oobsos"
      $ECHO
      #
      # On Linux we use sonames so the actual files are libesoobclient.so.1 and
      # libesoobclient_r.so.1 and they are symbolically linked to from
      # libesoobclient.so and libesoobclient_r.so. We want the symobolic links
      # on Linux but not elsewhere so we can't use -type l on find.
      # Also we don't know if this is .so, .a or .sl.
      # what we really want is "" or "_r" so we truncate on a . then take the stuff
      # after libesoobclient giving us "" or "_r".
      #
      for so in $oobsos
      do
        DRVTYP=`$ECHO "$so" | awk -F. '{print $1}' | sed -e 's/^.*libesoobclient\(.*\)$/\1/g'`
	DRVNAM="OOB$DRVTYP"
	DRVDESC="Easysoft ODBC-ODBC Bridge"
	if [ "$DRVTYP" != "" ];then
	  DRVDESC="$DRVDESC (MT)"
	fi
        TEMPLATE="oob.tmpl$DRVTYP"
        > $TEMPLATE
        $ECHO "[$DRVNAM]" >> $TEMPLATE
        $ECHO "Description = $DRVDESC" >> $TEMPLATE
        $ECHO "Driver = $so" >> $TEMPLATE
        $ECHO "Setup = $oobsetupso" >> $TEMPLATE
        #
	# Special case to add dontdlclose = 1 for HP-UX PARisc 2
	#
	pwd | grep parisc2 1>/dev/null 2>/dev/null
	if [ $? -eq 0 ];then
	    $ECHO "#Adding dontdlclose for HP-UX PARisc2 to avoid a hang in shl_load" >> $TEMPLATE
	    $ECHO "dontdlclose = 1" >> $TEMPLATE
	fi
	#cat $TEMPLATE
	$ECHO "Installing $so under unixODBC"
	if [ "$DRVTYP" = "_r" ];then
	  ./uodbc driver $TEMPLATE 'ODBC-ODBC Bridge client (MT)' OOB_r y
	else
	  ./uodbc driver $TEMPLATE 'ODBC-ODBC Bridge client' OOB
	fi
        if [ $? -ne 0 ]; then
          $ECHO "** Failed to install $DRVNAM for unixODBC **"
cat <<EOF
You can install this driver manually by appending the following text to
your odbcinst.ini file.
EOF
          cat $TEMPLATE
        fi
      done
      if [ "$TESTEXISTS" dsn_template ];then
        ./uodbc dsn dsn_template 'ODBC-ODBC Bridge' OOB "0"
      fi # dsn_template exists
    fi # successfully installed OOB under unixODBC
  fi # install OOB under unixODBC
  ####$ECHO "Press the return key to continue"
  ####read press
  cwd=`pwd`
  ./oob_create_dsn.sh $path/easysoft uodbc_tmp
  cd $cwd
  #
  # Perl?
  #
  if [ "$INSTALLED_CLIENT" = "y" ];then
    if [ -x ./is_perl.sh ];then
      ./is_perl.sh installed
      if [ $? -eq 0 ];then
        cat <<EOF
You appear to have Perl installed. If you are planning on using the OOB
Client with Perl we can test your current Perl setup and make recommendations.
  
EOF
        answer=""
        while [ \( "$answer" != "y" \) -a \( "$answer" != "n" \) ]
        do
  	$ECHO "Test Perl setup now (y/n) [y] : \c"
  	read answer
  	if [ "$answer" = "" ];then
  	  answer="y"
          fi
        done
        if [ "$answer" = "y" ]; then
  	if [ "$TESTEXISTS" uodbc_tmp ];then
  	  fnd=`cat uodbc_tmp`
          else
  	  fnd=""
          fi
  	./is_perl.sh check "$INSTALLED_UNIXODBC" "$fnd"
        fi
      fi
    fi
  fi
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 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).

EOF
  answer="hoho"
  sdef="n"
  if [ \( "$SKIPCLIENT" != "" \) -o \( "$INSTALLED_CLIENT" != "y" \) ];then
    sdef="y"
  fi
  while [ "$answer" != "" -a "$answer" != "y" -a "$answer" != "n" ]
  do
    $ECHO "Install ODBC-ODBC Bridge Server (y/n) [$sdef]: \c"
    read answer
    if [ "$answer" = "" ];then
      answer="$sdef"
    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
      sts=$?
      if [ "$TARV2STDERR"  = "1" ];then
	  cat "$TARSTDERROUTPUT";
      fi
      tarerr="n"
      if [ $sts -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 "****************************************"
	tarerr="y"
      else
  	output=`cat "$TARSTDERROUTPUT" 2>/dev/null | grep -v "blocksize" | grep -v "^x.*$"`
  	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 "****************************************"
	  tarerr="y"
  	fi
      fi
      if [ "$tarerr" = "y" ];then
	answer="hoho"
	while [ "$answer" != "y" -a "$answer" != "n" ]
	  do
	  $ECHO "Warnings were output above. Continue? (y/n) [n]: \c"
	  read answer
	  if [ "$answer" = "" ];then
	    answer="n"
	  fi
	  if [ "$answer" = "n" ];then
	    $ECHO "Installation terminated"
	    exit 99
	  fi
	done
      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
#
# see if we have systemd
#
$ECHO "Check if we have systemd"
installsystemd="n"
if [ -d /etc/systemd ];then
 sysctl=`which systemctl`
 if [ "$sysctl" = "" ];then
   $ECHO "The systemctl program does not exist on this system."
 else
  answer="haha"
  while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
  do
   $ECHO "Do you want to install to systemd? (y/n) [y]: \c"
   read answer
   if [ "$answer" = "" ];then
     answer="y"
   fi
  done
  installsystemd="$answer"
 fi
else
   $ECHO "The directory /etc/systemd does not exist on this system."
fi

if [ "$installsystemd" = "y" ];then
#
# root-specific install systemd
# =============================
#
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 systemd 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
cat <<EOF
This installer can now install systemd entries for the OOB Server.

EOF

#
#  Install the service
#
cwd=`pwd`
cd $path/easysoft/oob
sout="server/install/shell_startup.conf"
> $sout
$ECHO "#" >> $sout
$ECHO "[Unit]" >> $sout
$ECHO "Description = Easysoft OOB Server" >> $sout
$ECHO "" >> $sout
$ECHO "[Service]" >> $sout
$ECHO "Type=exec" >> $sout
$ECHO "ExecStart=/usr/local/easysoft/oob/server/server" >> $sout
$ECHO "" >> $sout
$ECHO "[Install]" >> $sout
$ECHO "WantedBy=multi-user.target" >> $sout
cp server/install/shell_startup.conf /etc/systemd/system/esoob.service
chmod ugo+x /etc/systemd/system/esoob.service

#
# Create the shell startup script
#
cd $path/easysoft/oob
sout="server/install/shell_startup.conf"
> $sout
$ECHO "#!/bin/sh" >> $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 standalone' >> $sout
cp server/install/shell_startup.conf server/server
chmod ugo+x server/server
cd $cwd
# 
# Using systemctl start the service
$sysctl daemon-reload
$sysctl start esoob.service

#
# Start automatically?
#
answer="haha"
while [ "$answer" != "" -a "$answer" != "n" -a "$answer" != "y" ]
do
 $ECHO "Do you want to start the OOB server automatically? (y/n) [y]: \c"
 read answer
 if [ "$answer" = "" ];then
   answer="y"
 fi
done

if [ "$answer" = "y" ];then
 $sysctl enable esoob.service
fi

$ECHO "OOB Server installed to systemd"
$ECHO ""
$ECHO "Press the return key to continue"
read press
#
else
#
#
# root-specific install (inetd)
# =====================
#
if [ "$platform" != "interix" ];then
  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
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 'oob' server ""
  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 "#!/bin/sh" >> $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
fi
$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
