#!/bin/sh

# Location of the Opera binary
OPERA=/usr/lib/opera/6.0-20020510.2/opera

if test ! -f $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 /usr/share/opera ; then 
    OPERA_DIR=/usr/share/opera
  else
    echo "OPERA_DIR unset and not in default location (/usr/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" \
    /usr/lib/opera/plugins \
    /usr/local/lib/opera/plugins \
    /opt/lib/opera/plugins \
    /usr/local/Acrobat[45]/Browsers/intellinux \
    /usr/lib/Acrobat[45]/Browsers/intellinux \
    /usr/X11R6/lib/Acrobat[45]/Browsers/intellinux \
    /opt/Acrobat[45]/Browsers/intellinux \
    /usr/Acrobat[45]/Browsers/intellinux \
    /usr/j2se/jre/plugin/i386/ns4 \
    /usr/java/jre1.4.0/plugin/i386/ns4 \
    /usr/java/jre1.3.1/plugin/i386/ns4 \
    /usr/lib/j2re1.3/plugin/i386/netscape4 \
    /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
for BINDIR in \
    /usr/local/Acrobat[45]/bin \
    /usr/lib/Acrobat[45]/bin \
    /usr/X11R6/lib/Acrobat[45]/bin \
    /opt/Acrobat[45]/bin \
    /usr/Acrobat[45]/bin \
    ; do
    if test -d $BINDIR ; then PATH=$PATH:$BINDIR; fi
done

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

# Running Opera
$OPERA "$@"
