#! /bin/sh
#
# Tiny startup wrapper for arriba
#
# Copyright (c) 2009, Sebastian Hilbert <sebastian.hilbert@gmx.net>
#
# Licensed under the GNU General Public License, version 2
#

ARRIBA_HOME=${ARRIBA_HOME:="/usr/lib/arriba"}
ARRIBA_BIN="${ARRIBA_HOME}/arriba.jar"

if [ ! ${ARRIBA_BIN} ] ; then
	echo "Failed to find executable '${ARRIBA_BIN}'" > /dev/stderr
	exit -1
fi

if [ $(id -u) -eq 0 ] ; then
	echo "Do not run arriba as root user! Exiting ..."
	exit -1
fi

if [[ "$(java-config -f)" =~ "gcj" ]] ; then
	echo "Arriba does not yet run on GCJ. Please install SUN JRE/SDK ..." > /dev/stderr
	exit -1
fi

#exec $(java-config --java) -jar ${ARRIBA_BIN}
exec java -jar ${ARRIBA_BIN} $@