#!/bin/sh

memory='' # system default

case "`uname`" in
	FreeBSD|Darwin)
		memory=`sysctl -n hw.usermem \
			|awk '{printf("%d", $0 / 1024 / 1024 * 0.85)}'`
		if [ $memory -gt 1536 ]; then
			memory=1536
		elif [ $memory -lt 64 ]; then
			memory=''
		fi
		;;

	Linux)
		;;

	*)
		;;
esac

memory_option=''
if [ X"${memory}" != X'' ]; then
	memory_option="-Xmx${memory}m"
fi

exec java -server -ea ${memory_option} -Dfile.encoding=utf-8 -jar daruma.jar $@
