#!/sbin/sh
# @(#) preinstall.sd - SQL/R A.04.00
# SD installation pre-install procedure, HP-UX 11.x
# (C) Copyright 2010-2022 Marxmeier Software AG. All rights reserved.
#
# Run by swinstall before install phase.
#

if [[ ${SW_ROOT_DIRECTORY} != "/" ]]
then
   exit 0
fi

# setup PATH
PATH=$SW_PATH
export PATH

rval=0

# base directory may be a symlink

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

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

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

# remove obsolete symlinks

for d in $SQLR_base /etc$SQLR_base /var$SQLR_base
do
   if [ -e $d -a -h $d ]; then
      echo "NOTE:    Removing conflicting symlink $d"
      rm -f $d || rval=1
   fi
done

exit $rval
