#! /bin/bash

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

latest_firefox=`ls -1rdt /usr/lib/firefox* 2> /dev/null | tail -n 1`

if [ -n "$latest_firefox" ]
then
    # we found a /usr/lib/firefox* directory
    if [ -f "$latest_firefox/libgtkembedmoz.so" ]
    then
        # and it contains a libgtkembedmoz.so file
        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
    fi
fi

exec $0.bin "$@"
