#!/bin/sh
# Use this if you don't want to install Opera to any special location,
# but execute it from the extracted package or current location.

OP_ARCH=$(uname -m)
case ${OP_ARCH} in
  x86_64 | ia64 | s390 )
    OP_LIB_DIR="/usr/lib64"
    SECONDARY_LIB_DIR="/usr/lib"
    ;;
  * )
    OP_LIB_DIR="/usr/lib"
    SECONDARY_LIB_DIR="/usr/lib64"
    ;;
esac

if [ ! -x ${OP_LIB_DIR}/opera/opera ]; then
  if [ ! -x ${SECONDARY_LIB_DIR/}opera/opera ]; then
    echo "Error: ${OP_LIB_DIR}/opera/opera not found"
    if [ -d ${SECONDARY_LIB_DIR} ]; then
      echo "       ${SECONDARY_LIB_DIR}/opera/opera not found"
    fi
    exit 1
  fi
  OP_LIB_DIR="${SECONDARY_LIB_DIR}"
fi

# Location of the Opera binaries
export OPERA_BINARYDIR=${OP_LIB_DIR}/opera

export OPERA_DIR=${OPERA_DIR:-/usr/share/opera}
export OPERA_PERSONALDIR=${OPERA_PERSONALDIR:-${HOME}/.opera}
exec "${OPERA_BINARYDIR}/opera" "$@"
