#!/bin/sh
spluslocker=/mit/splus_v8.0
if test -s /etc/athena/reactivate
then
isathena=1
ATHENA_SYS=${ATHENA_SYS-`machtype -S`}
if [ `echo $ATHENA_SYS | awk '{ print substr($1,1,8)}'` = "i386_deb" ]
then
isi386athena10=1
else
isi386athena10=0
fi
else
isathena=0
export ATHENA_SYS=`fs sysname | awk '{ print substr($4,2,length($4)-2)}'`
# next line removes "Cannot convert string... errors
#xprop -root -remove _MOTIF_DEFAULT_BINDINGS
PATH=${spluslocker}/arch/${ATHENA_SYS}/bin:$PATH
fi
# for Athena 10, need hacked libx11.so to avoid locking errors 
if [ "$isi386athena10" = "1" ]
then
  if test ${LD_LIBRARY_PATH-undefined} = "undefined"
  then
    LD_LIBRARY_PATH="${spluslocker}/lib"
  else
    LD_LIBRARY_PATH="${spluslocker}/lib:${LD_LIBRARY_PATH}"
  fi
export LD_LIBRARY_PATH
fi

###############################################
# alexp 7/24/07
# need to script wrap Java version to record launch - wrapper doesn't work
if [ $# -gt 0 ]
then
if [ $1 = "-g" ]
then
machine=`machtype`
software=splusjava
version=8.0
when=`date '+%m,%d,%y,%H,%M,%S'`
output="${when},${software},${machine},${version},${isathena}"
echo $output >> "/afs/athena/software/scriptlogs/log"
fi
fi
###############################################
splushome=`athdir -f "${spluslocker}/distrib/%s"`
if [ $isathena -eq 1 ]
then
attach -q infoagents
else
attach infoagents
fi
PATH=`athdir /mit/infoagents`:$PATH; export PATH

PATH_TO_UTILS=`athdir -p /afs/athena/software/swtools -t bin`
delete_prog="${PATH_TO_UTILS}/delete_cookie.pl"
message_prog="${PATH_TO_UTILS}/send_message.pl"
#cookie="splus6avail"
#$delete_prog $cookie

# set ATHENA_SYS if not already set
ATHENA_SYS=${ATHENA_SYS-`machtype -S`}; export ATHENA_SYS

# set printer if not already set
myhost=`hostname`
altprinter=`hesinfo $myhost cluster 2> /dev/null | grep lpr | awk '{print $2}'`
PRINTER=${PRINTER-${altprinter}}; export PRINTER
S_CLEDITOR=emacs; export S_CLEDITOR
IFUL_LICENSE_FILE=${splushome}/adm/lic/keys
export IFUL_LICENSE_FILE
exec ${splushome}/cmd/Splus "$@"

