#!/bin/sh
#
#	$NetBSD: soffice,v 1.5 2004/01/25 16:57:57 mrauch Exp $
#
SOINST=@@PREFIX@@/OpenOffice.org1.1.0
[ "$SOFFICE" = "" ] && SOFFICE=$HOME/OpenOffice.org1.1.0

if [ `uname -s` = "NetBSD" -a ! -r /emul/linux/etc/mtab ]; then
	echo 'ERROR: Before you are able to use this package, the file'
	echo '       /emul/linux/etc/mtab must exist.'
        echo '       Ask your system administrator to create this file,'
	echo '       e.g. by running "touch /emul/linux/etc/mtab".'
	exit 1
fi

if [ ! -d "$SOFFICE" ]; then
	echo ""
	echo "-----------------------------------------------------------------"
	echo "  OpenOffice has not yet been set up for `whoami`."
	echo "  Starting setup ...                                             "
	echo ""
	echo "  (If OpenOffice has already been set up for `whoami` or you"
	echo "  want to install it someplace other than $SOFFICE"
	echo "  please abort the installation procedure now, set the \$SOFFICE "
	echo "  environment variable accordingly and rerun $0.)"
	echo "-----------------------------------------------------------------"
	echo ""

	# add an existing java directory to $PATH to allow OO to
	# automatically find it
	#
	if [ -n "$JAVA_HOME" -a -f "$JAVA_HOME/bin/java" ]; then
		export PATH=$PATH:$JAVA_HOME/bin
	fi

	cd $SOINST
	./setup

	echo ""
	echo "Done.  Starting OpenOffice ..."
	echo ""
fi

# We've got a large number of shared libraries and other single files which 
# have to be open for normal operation
ulimit -n `ulimit -n -H`

exec ${SOFFICE}/soffice "$@"
