#!/bin/sh
# ESP Package Manager v3.7.0

# echo Command after installing
# searching for the PRODUCTINSTALLLOCATION for the different platforms
platform=`uname -s`
case $platform in
SunOS)
  PRODUCTINSTALLLOCATION="$BASEDIR"
  ;;
Linux)
  PRODUCTINSTALLLOCATION="$RPM_INSTALL_PREFIX"
  ;;
*)
  PRODUCTINSTALLLOCATION="$BASEDIR" 
  ;;
esac

uid=`id | sed -e 's/(.*//' -e 's/^uid=//'` 
if [ "$uid" = "0" ]
then
  # removing an existing link
  if [ -h /usr/bin/soffice ]
  then
    rm -f /usr/bin/soffice 2>/dev/null
  fi
  # creating link /usr/bin/soffice
  ln -s $PRODUCTINSTALLLOCATION/program/soffice /usr/bin/soffice >/dev/null 2>&1
fi

# creating link to libfreetype.so.6, if necessary
if [ ! -f /usr/lib/libfreetype.so.6 ]
then
  if [ ! -f $PRODUCTINSTALLLOCATION/program/libfreetype.so.6 ]
  then
    if [ -f $PRODUCTINSTALLLOCATION/program/filter/libfreetype.so.6 ]
    then
      ln -s filter/libfreetype.so.6 $PRODUCTINSTALLLOCATION/program/libfreetype.so.6 >/dev/null 2>&1
    fi
  fi
fi

exit 0
