1#! /bin/sh 2# Generic freecol start script. 3# Please customize this for your distribution. 4# Look at the debian scripts for other ideas, they are clueful. 5# 6# Things this script needs to do: 7# - Find the freecol data directory. 8# It is usually called "data". 9# Try to allow the --freecol-data command line override to work. 10# This script allows a FREECOL_DATA environment variable override, 11# tries the obvious directories, and puts the result in FCDAT. 12# - Find the freecol .jar. 13# It is usually called "FreeCol.jar". 14# This script allows a FREECOL_JAR environment variable override, 15# tries the obvious directories, and puts the result in FCJAR. 16# - Find the java binary. 17# This script assumes it is "java". 18# If not, fix the last line. 19# 20BINDIR=`dirname "$0"` 21FREECOLDATA="data" 22FREECOLJAR="FreeCol.jar" 23 24# Find the data directory, put it in FCDAT. 25FCDAT="" 26# Is the data directory supplied in the command line args? 27for x in $@ ; do 28 if test "x$x" = "x--freecol-data" ; then 29 FCDAT="DONTSET!" 30 break 31 fi 32done 33# - Is there a credible FREECOL_DATA environment variable? 34if test "x${FCDAT}" = "x" ; then 35 if test "x${FREECOL_DATA}" != "x" -a -d "${FREECOL_DATA}" ; then 36 FCDAT="${FREECOL_DATA}" 37# - Is it in the current directory? 38 elif test -d "${FREECOLDATA}" ; then 39 FCDAT="DONTSET!" 40# - Is it where this script is? 41 elif test -d "${BINDIR}/${FREECOLDATA}" ; then 42 FCDAT="${BINDIR}/${FREECOLDATA}" 43# - Is it in a likely linux FHS place? 44 elif test -d "/usr/share/freecol/data" ; then 45 FCDAT="/usr/share/freecol/data" 46# - It it in $HOME/freecol? 47 elif test "x${HOME}" != "x" -a -d "${HOME}/freecol" \ 48 -a -d "${HOME}/freecol/${FREECOLDATA}" ; then 49 FCDAT="${HOME}/freecol/${FREECOLDATA}" 50# - Give up. 51 else 52 echo "can not find freecol data directory" >&2 53 exit 1 54 fi 55fi 56 57# Find the freecol jar, put it in FCJAR. 58FCJAR="" 59# - Is there a credible FREECOL_JAR environment variable? 60if test "x${FREECOL_JAR}" != "x" -a -r "${FREECOL_JAR}" ; then 61 FCJAR="${FREECOL_JAR}" 62# - Is it in the current directory? 63elif test -r "${FREECOLJAR}" ; then 64 FCJAR="${FREECOLJAR}" 65# - Is it where this script is? 66elif test -r "${BINDIR}/${FREECOLJAR}" ; then 67 FCJAR="${BINDIR}/${FREECOLJAR}" 68# - Is it in a likely linux FHS place? 69elif test -d "/usr/share/java/${FREECOLJAR}" ; then 70 FCJAR="/usr/share/java/${FREECOLJAR}" 71# Give up. 72else 73 echo "can not find ${FREECOLJAR}" >&2 74 exit 1 75fi 76 77# Clean up the data argument and run. 78if test "x${FCDAT}" = "xDONTSET!" ; then 79 exec java -Xmx512M -cp "${FCJAR}" net.sf.freecol.FreeCol ${1+"$@"} 80else 81 exec java -Xmx512M -cp "${FCJAR}" net.sf.freecol.FreeCol --freecol-data "${FCDAT}" ${1+"$@"} 82fi 83