#!/bin/bash

#
# sample script to fake the Simple PreProcessing Protocol (use with the SRG)
# 


#
# include a shared set of shell functions and global parameters, including the
# architecture identifier .LOGONOS.
#
if [ -n "${LOGONROOT}" ]; then
  . ${LOGONROOT}/etc/library.bash;
fi

user=${USER}
if [ -z "${user}" ]; then user=$(whoami); fi

if [ -f ${HOME}/.freelingrc ]; then
  . ${HOME}/.freelingrc
fi

if [ -z "${FREELINGANALYZER}" ]; then
  export FREELINGANALYZER=${LOGONROOT}/upc/bin/freelingSPPP
fi
if [ -z "${FREELINGCFG}" ]; then
  export FREELINGCFG=${LOGONROOT}/upf/srg/freeling/logon.cfg
fi
if [ -z "${FREELINGSHARE}" ]; then
  export FREELINGSHARE=${LOGONROOT}/upc/share/freeling
fi
if [ -z "${FREELINGSPPP}" ]; then
  export FREELINGSPPP=${LOGONROOT}/upf/srg/freeling/sppp.dat
fi
if [ -z "${FREELINGLIBS}" ]; then
  export LD_LIBRARY_PATH=${LOGONROOT}/upc/lib:${LD_LIBRARY_PATH}
else 
  export LD_LIBRARY_PATH=${FREELINGLIBS}:${LD_LIBRARY_PATH}
fi

#
# when running as part of the LOGON tree, FreeLing is part of the same tree,
# i.e. there is no need to have additional tools installed locally.  ideally,
# the LOGON tree (including the SRG) will be functional an a wide rage of Linux
# distributions, not assuming any non-standard additional packages.
#

##echo "command= "${FREELINGANALYZER} -f ${FREELINGCFG}
cd ${LOGONROOT};
exec ${FREELINGANALYZER} -f ${FREELINGCFG} 2> /tmp/freeling.debug.${user};