#!/bin/sh

dist_bin=`dirname $0`

if test -n "$MOZILLA_FIVE_HOME"; then
	MOZILLA_HOME=$MOZILLA_FIVE_HOME
elif [ -f @MOZILLA_HOME@/chrome/comm.jar ]; then
	MOZILLA_HOME=@MOZILLA_HOME@
elif [ -f /usr/local/mozilla/chrome/comm.jar ]; then
	MOZILLA_HOME=/usr/local/mozilla
elif [ -f /usr/lib/mozilla/chrome/comm.jar ]; then
	MOZILLA_HOME=/usr/lib/mozilla
elif [ -f /opt/mozilla/chrome/comm.jar ]; then
	MOZILLA_HOME=/opt/mozilla
elif [ -f /usr/lib/mozilla-0.9.7/chrome/comm.jar ]; then
	MOZILLA_HOME=/usr/lib/mozilla-0.9.7/
elif [ -f /opt/gnome/lib/mozilla/chrome/comm.jar ]; then
        MOZILLA_HOME=/opt/gnome/lib/mozilla/
else
	echo "Cannot find mozilla installation directory. Please set MOZILLA_FIVE_HOME to your mozilla directory"
	exit
fi

LD_LIBRARY_PATH=$MOZILLA_HOME:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

MOZILLA_FIVE_HOME=$MOZILLA_HOME
export MOZILLA_FIVE_HOME

# for some reason this lets Galeon start properly on Red Hat 7.1 systems
if [ -f /etc/redhat-release ]; then
	if [ "`cat /etc/redhat-release`" = "Red Hat Linux release 7.1 (Seawolf)"  ]; then
   	 export LD_ASSUME_KERNEL=2.2.5
	fi
fi

if [ -f ./galeon-bin ]; then
exec ./galeon-bin "$@"
else
exec $dist_bin/galeon-bin "$@"
fi

