#! /bin/bash

# this script sets MOZILLA_FIVE_HOME and LD_LIBRARY_PATH as needed
# by the gtkmozembed python module.

for p in /usr/lib{64,}/{xulrunner*,firefox*}/lib{xul,gtkembedmoz}.so; do
  [ -f "$p" ] || continue
  latest_firefox="$(dirname "$p")"/
  export LD_LIBRARY_PATH="$latest_firefox":$LD_LIBRARY_PATH
  # only set MOZILLA_FIVE_HOME if not set already
  [ -n "$MOZILLA_FIVE_HOME" ] || export MOZILLA_FIVE_HOME="$latest_firefox"
  # We need only the first directory found
  break
done

exec `basename \`readlink -f $0\``.bin "$@"
