Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / distribution / opendaylight / src / main / resources / run.sh
1 #!/bin/bash
2
3 [[ -z ${JAVA_HOME} ]] && echo "Need to set JAVA_HOME environment variable" && exit -1;
4 [[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
5 JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
6
7 platform='unknown'
8 unamestr=`uname`
9 if [[ "$unamestr" == 'Linux' ]]; then
10    platform='linux'
11 elif [[ "$unamestr" == 'Darwin' ]]; then
12    platform='osx'
13 fi
14
15 if [[ $platform == 'linux' ]]; then
16    fullpath=`readlink -f $0`
17 elif [[ $platform == 'osx' ]]; then
18    TARGET_FILE=$0
19    cd `dirname $TARGET_FILE`
20    TARGET_FILE=`basename $TARGET_FILE`
21
22    # Iterate down a (possible) chain of symlinks
23    while [ -L "$TARGET_FILE" ]
24    do
25        TARGET_FILE=`readlink $TARGET_FILE`
26        cd `dirname $TARGET_FILE`
27        TARGET_FILE=`basename $TARGET_FILE`
28    done
29
30    # Compute the canonicalized name by finding the physical path
31    # for the directory we're in and appending the target file.
32    PHYS_DIR=`pwd -P`
33    RESULT=$PHYS_DIR/$TARGET_FILE
34    fullpath=$RESULT
35 fi
36
37 basedir=`dirname ${fullpath}`
38
39 ########################################
40 # Now add to classpath the OSGi JAR
41 ########################################
42 CLASSPATH=${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
43 FWCLASSPATH=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
44
45 ########################################
46 # Now add the extensions
47 ########################################
48
49 # Extension 1: this is used to be able to convert all the
50 # bundleresouce: URL in file: so packages that are not OSGi ready can
51 # still work. Notably this is the case for spring classes
52 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
53 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
54
55 ########################################
56 # Now add the launcher
57 ########################################
58 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
59 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
60
61 $JAVA_HOME/bin/java $@ \
62     -Djava.io.tmpdir=${basedir}/work/tmp \
63     -Dosgi.install.area=${basedir} \
64     -Dosgi.configuration.area=${basedir}/configuration \
65     -Dosgi.frameworkClassPath=${FWCLASSPATH} \
66     -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
67     -classpath ${CLASSPATH} \
68     org.eclipse.equinox.launcher.Main \
69     -console \
70     -consoleLog