wildfire.sh 3.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
#!/bin/sh

#
# $RCSfile$
# $Revision: 1194 $
# $Date: 2005-03-30 13:39:54 -0300 (Wed, 30 Mar 2005) $
#

# tries to determine arguments to launch wildfire

# OS specific support.  $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
case "`uname`" in
  CYGWIN*) cygwin=true ;;
  Darwin*) darwin=true
           if [ -z "$JAVA_HOME" ] ; then
             JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
           fi
           ;;
esac

#if wildfire home is not set or is not a directory
if [ -z "$WILDFIRE_HOME" -o ! -d "$WILDFIRE_HOME" ]; then

	if [ -d /opt/wildfire ] ; then
		WILDFIRE_HOME="/opt/wildfire"
	fi

	if [ -d /usr/local/wildfire ] ; then
		WILDFIRE_HOME="/usr/local/wildfire"
	fi

	if [ -d ${HOME}/opt/wildfire ] ; then
		WILDFIRE_HOME="${HOME}/opt/wildfire"
	fi

	#resolve links - $0 may be a link in wildfire's home
	PRG="0"
	progname=`basename "$0$"`

	# need this for relative symlinks

	# need this for relative symlinks
  	while [ -h "$PRG" ] ; do
    		ls=`ls -ld "$PRG"`
    		link=`expr "$ls" : '.*-> \(.*\)$'`
    		if expr "$link" : '/.*' > /dev/null; then
    			PRG="$link"
    		else
    			PRG=`dirname "$PRG"`"/$link"
    		fi
  	done

	#assumes we are in the bin directory
	WILDFIRE_HOME=`dirname "$PRG"`/..

	#make it fully qualified
	WILDFIRE_HOME=`cd "$WILDFIRE_HOME" && pwd`
fi
WILDFIRE_OPTS="${WILDFIRE_OPTS} -DwildfireHome=${WILDFIRE_HOME}"


# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
	[ -n "$WILDFIRE_HOME" ] &&
    		WILDFIRE_HOME=`cygpath --unix "$WILDFIRE_HOME"`
  	[ -n "$JAVA_HOME" ] &&
    		JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

#set the WILDFIRE_LIB location
WILDFIRE_LIB="${WILDFIRE_HOME}/lib"
WILDFIRE_OPTS="${WILDFIRE_OPTS} -Dwildfire.lib.dir=${WILDFIRE_LIB}"


if [ -z "$JAVACMD" ] ; then
  	if [ -n "$JAVA_HOME"  ] ; then
    		if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
      			# IBM's JDK on AIX uses strange locations for the executables
      			JAVACMD="$JAVA_HOME/jre/sh/java"
    		else
      			JAVACMD="$JAVA_HOME/bin/java"
    		fi
  	else
    		JAVACMD=`which java 2> /dev/null `
    		if [ -z "$JAVACMD" ] ; then
        		JAVACMD=java
    		fi
  	fi
fi

if [ ! -x "$JAVACMD" ] ; then
  	echo "Error: JAVA_HOME is not defined correctly."
  	echo "  We cannot execute $JAVACMD"
  	exit 1
fi

if [ -z "$LOCALCLASSPATH" ] ; then
	LOCALCLASSPATH=$WILDFIRE_LIB/startup.jar
else
      	LOCALCLASSPATH=$WILDFIRE_LIB/startup.jar:$LOCALCLASSPATH
fi

# For Cygwin, switch paths to appropriate format before running java
if $cygwin; then
  	if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
    		format=mixed
  	else
    		format=windows
  	fi
  	WILDFIRE_HOME=`cygpath --$format "$WILDFIRE_HOME"`
  	WILDFIRE_LIB=`cygpath --$format "$WILDFIRE_LIB"`
  	JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
  	LOCALCLASSPATH=`cygpath --path --$format "$LOCALCLASSPATH"`
  	if [ -n "$CLASSPATH" ] ; then
    		CLASSPATH=`cygpath --path --$format "$CLASSPATH"`
  	fi
  	CYGHOME=`cygpath --$format "$HOME"`
fi

# add a second backslash to variables terminated by a backslash under cygwin
if $cygwin; then
  case "$WILDFIRE_HOME" in
    *\\ )
    WILDFIRE_HOME="$WILDFIRE_HOME\\"
    ;;
  esac
  case "$CYGHOME" in
    *\\ )
    CYGHOME="$CYGHOME\\"
    ;;
  esac
  case "$LOCALCLASSPATH" in
    *\\ )
    LOCALCLASSPATH="$LOCALCLASSPATH\\"
    ;;
  esac
  case "$CLASSPATH" in
    *\\ )
    CLASSPATH="$CLASSPATH\\"
    ;;
  esac
fi

wildfire_exec_command="exec \"$JAVACMD\" -server $WILDFIRE_OPTS -classpath \"$LOCALCLASSPATH\" -jar \"$WILDFIRE_LIB\"/startup.jar"
eval $wildfire_exec_command