#!/bin/sh

# Location of the Opera binary
OPERA=/mit/opera/lib/opera/6.0-20020110.1/opera

if test ! -e ${OPERA}; then
    echo "The Opera binary is not located at \"${OPERA}\"."
    echo "Please modify the wrapper script at \"${0}\"."
    exit 1
elif test ! -x ${OPERA}; then
    echo "You do not have execute rights on \"${OPERA}\", please ask the sysadmin to chmod +x it."
    exit 1
fi

# Opera enviroment
if test "${OPERA_DIR}" = '' ; then 
  if test -d /mit/opera/share/opera ; then 
    OPERA_DIR=/mit/opera/share/opera
  else
    echo "OPERA_DIR unset and not found at expected location (/mit/opera/share/opera)"
    exit 1
  fi
fi

# Opera Plug-in enviroment, Add more plugin search paths here
# If OPERA_PLUGIN_PATH is set NPX_PLUGIN_PATH will be ignored

for DIR in \
    "${HOME}/.opera/plugins" \
    /mit/opera/lib/opera/plugins \
    /usr/lib/opera/plugins \
    /usr/local/Acrobat4/Browsers/intellinux \
    /usr/java/jre1.3.1/plugin/i386/ns4 \
    /usr/lib/RealPlayer8/Plugins \
    /usr/lib/realplay/plugins \
    /usr/lib/RealPlayer8 \
    /usr/lib/realplay \
    "${HOME}/.netscape/plugins" \
    /opt/netscape/plugins \
    /usr/lib/netscape/plugins \
    /usr/local/netscape/plugins \
    /usr/local/lib/netscape/plugins \
    ; do
    if test -d ${DIR} ; then 
	OPERA_PLUGIN_PATH="${OPERA_PLUGIN_PATH}":"${DIR}"
    fi
done

# Acrobat Reader
if test -d /mit/acro ; then
    PATH=${PATH}:/mit/acro/bin
fi

OPERA_PLUGIN_PATH="${OPERA_PLUGIN_PATH}":"${NPX_PLUGIN_PATH}"
 
# Exporting the enviroment
export OPERA_DIR OPERA_PLUGIN_PATH

# Running Opera
${OPERA} "${@}"

