#!/sbin/sh
# @(#) checkinstall.sd - SQL/R A.04.00
# SD installation prerequisite check, HP-UX 11.x
# (C) Copyright 2010-2022 Marxmeier Software AG. All rights reserved.
#
# Run by swinstall during its analysis phase to insure that
# the installation (and configuration) can be attempted.
# For example, the OS run state, running processes, or other
# prerequisite conditions beyound SD dependencies could be checked.
# It should not change the state of the system.
#

# setup PATH

PATH=$SW_PATH
export PATH

rval=0

# check if SQL/R related process is active

SQLR_base=/opt/sqlr
SQLR=$SQLR_base/4.0

if [ -f ${SQLR}/bin/sqlrodbcd ]
then
   pid=$(/usr/sbin/fuser ${SQLR}/bin/sqlrodbcd 2>/dev/null)
   if [ -n "$pid"  ]
   then
      echo "ERROR:   SQL/R is active; sqlrodbcd process $pid running"
      rval=1
   fi
fi

[ $rval -eq 0 ] || exit $rval

# check base directory

for d in $SQLR_base /etc$SQLR_base /var$SQLR_base
do
   if [ -e $d -a ! -h $d -a ! -d $d ]; then
      echo "ERROR:   File $d conflicting with SQL/R installation"
      rval=1
   fi
done

exit $rval
