5 if [[ "$unamestr" == 'Linux' ]]; then
7 elif [[ "$unamestr" == 'Darwin' ]]; then
11 if [[ $platform == 'linux' ]]; then
12 fullpath=`readlink -f $0`
14 [[ -z ${JAVA_HOME} ]] && [[ -x "/usr/lib/jvm/java-1.7.0" ]] && export JAVA_HOME='/usr/lib/jvm/java-1.7.0';
16 elif [[ $platform == 'osx' ]]; then
18 cd `dirname $TARGET_FILE`
19 TARGET_FILE=`basename $TARGET_FILE`
21 # Iterate down a (possible) chain of symlinks
22 while [ -L "$TARGET_FILE" ]
24 TARGET_FILE=`readlink $TARGET_FILE`
25 cd `dirname $TARGET_FILE`
26 TARGET_FILE=`basename $TARGET_FILE`
29 # Compute the canonicalized name by finding the physical path
30 # for the directory we're in and appending the target file.
32 RESULT=$PHYS_DIR/$TARGET_FILE
35 [[ -z ${JAVA_HOME} ]] && [[ -x "/usr/libexec/java_home" ]] && export JAVA_HOME=`/usr/libexec/java_home -v 1.7`;
39 [[ -z ${JAVA_HOME} ]] && echo "Need to set JAVA_HOME environment variable" && exit -1;
40 [[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
41 JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
43 basedir=`dirname ${fullpath}`
46 echo "Usage: $0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
50 if [ -z ${TMP} ]; then
51 pidfile="/tmp/opendaylight.PID"
53 pidfile="${TMP}/opendaylight.PID"
73 -debug) debug=1; shift ;;
74 -jmx) startjmx=1; shift ;;
75 -debugsuspend) debugsuspend=1; shift ;;
76 -debugport) shift; debugportread="$1"; if [[ "${debugportread}" =~ ^[0-9]+$ ]] ; then debugport=${debugportread}; shift; else echo "-debugport expects a number but was not found"; exit -1; fi;;
77 -jmxport) shift; jmxportread="$1"; if [[ "${jmxportread}" =~ ^[0-9]+$ ]] ; then jmxport=${jmxportread}; shift; else echo "-jmxport expects a number but was not found"; exit -1; fi;;
78 -start) startdaemon=1; shift; daemonportread="$1"; if [[ "${daemonportread}" =~ ^[0-9]+$ ]] ; then daemonport=${daemonportread}; shift; fi;;
79 -stop) stopdaemon=1; shift ;;
80 -status) statusdaemon=1; shift ;;
82 -help) dohelp=1; shift;;
83 -D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
84 -X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
86 *) echo "Unknown option $1"; unknown_option=1; shift ;;
90 # Unknown Options and help
91 if [ "${unknown_option}" -eq 1 ]; then
95 if [ "${dohelp}" -eq 1 ]; then
100 if [[ "${debugport}" -lt 1024 ]] || [[ "${debugport}" -gt 65535 ]]; then
101 echo "Debug Port not in the range [1024,65535] ${debugport}"
105 # Validate daemon console port
106 if [[ "${daemonport}" -lt 1024 ]] || [[ "${daemonport}" -gt 65535 ]]; then
107 echo "Daemon console Port not in the range [1024,65535] value is ${daemonport}"
112 if [[ "${jmxport}" -lt 1024 ]] || [[ "${jmxport}" -gt 65535 ]]; then
113 echo "JMX Port not in the range [1024,65535] value is ${jmxport}"
118 if [ "${debugsuspend}" -eq 1 ]; then
119 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debugport}"
120 elif [ "${debug}" -eq 1 ]; then
121 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debugport}"
125 if [ "${startjmx}" -eq 1 ]; then
126 extraJVMOpts="${extraJVMOpts} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=${jmxport} -Dcom.sun.management.jmxremote"
129 ########################################
130 # Now add to classpath the OSGi JAR
131 ########################################
132 CLASSPATH=${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
133 FWCLASSPATH=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
135 ########################################
136 # Now add the extensions
137 ########################################
139 # Extension 1: this is used to be able to convert all the
140 # bundleresouce: URL in file: so packages that are not OSGi ready can
141 # still work. Notably this is the case for spring classes
142 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
143 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
145 ########################################
146 # Now add the launcher
147 ########################################
148 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
149 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
151 if [ "${stopdaemon}" -eq 1 ]; then
152 if [ -e "${pidfile}" ]; then
153 daemonpid=`cat "${pidfile}"`
156 echo "Controller with PID: ${daemonpid} -- Stopped!"
159 echo "Doesn't seem any Controller daemon is currently running"
164 if [ "${statusdaemon}" -eq 1 ]; then
165 if [ -e "${pidfile}" ]; then
166 daemonpid=`cat "${pidfile}"`
167 ps -p ${daemonpid} > /dev/null
169 if [ "${daemonexists}" -eq 0 ]; then
170 echo "Controller with PID: ${daemonpid} -- Running!"
173 echo "Controller with PID: ${daemonpid} -- Doesn't seem to exist"
178 echo "Doesn't seem any Controller daemon is currently running, at least no PID file has been found"
183 if [ "${startdaemon}" -eq 1 ]; then
184 if [ -e "${pidfile}" ]; then
185 echo "Another instance of controller running, check with $0 -status"
188 $JAVA_HOME/bin/java ${extraJVMOpts} \
189 -Djava.io.tmpdir=${basedir}/work/tmp \
190 -Dosgi.install.area=${basedir} \
191 -Dosgi.configuration.area=${basedir}/configuration \
192 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
193 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
194 -classpath ${CLASSPATH} \
195 org.eclipse.equinox.launcher.Main \
196 -console ${daemonport} \
199 echo ${daemonpid} > ${pidfile}
200 elif [ "${consolestart}" -eq 1 ]; then
201 if [ -e "${pidfile}" ]; then
202 echo "Another instance of controller running, check with $0 -status"
205 $JAVA_HOME/bin/java ${extraJVMOpts} \
206 -Djava.io.tmpdir=${basedir}/work/tmp \
207 -Dosgi.install.area=${basedir} \
208 -Dosgi.configuration.area=${basedir}/configuration \
209 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
210 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
211 -classpath ${CLASSPATH} \
212 org.eclipse.equinox.launcher.Main \