5 if [[ "$unamestr" == 'Linux' ]]; then
7 elif [[ "$unamestr" == 'Darwin' ]]; then
11 if [[ $platform == 'linux' ]]; then
12 fullpath=`readlink -f $0`
13 elif [[ $platform == 'osx' ]]; then
15 cd `dirname $TARGET_FILE`
16 TARGET_FILE=`basename $TARGET_FILE`
18 # Iterate down a (possible) chain of symlinks
19 while [ -L "$TARGET_FILE" ]
21 TARGET_FILE=`readlink $TARGET_FILE`
22 cd `dirname $TARGET_FILE`
23 TARGET_FILE=`basename $TARGET_FILE`
26 # Compute the canonicalized name by finding the physical path
27 # for the directory we're in and appending the target file.
29 RESULT=$PHYS_DIR/$TARGET_FILE
32 [[ -z ${JAVA_HOME} ]] && [[ -x "/usr/libexec/java_home" ]] && export JAVA_HOME=`/usr/libexec/java_home -v 1.7`;
36 [[ -z ${JAVA_HOME} ]] && echo "Need to set JAVA_HOME environment variable" && exit -1;
37 [[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
38 JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
40 basedir=`dirname ${fullpath}`
43 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>]"
47 if [ -z ${TMP} ]; then
48 pidfile="/tmp/opendaylight.PID"
50 pidfile="${TMP}/opendaylight.PID"
70 -debug) debug=1; shift ;;
71 -jmx) startjmx=1; shift ;;
72 -debugsuspend) debugsuspend=1; shift ;;
73 -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;;
74 -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;;
75 -start) startdaemon=1; shift; daemonportread="$1"; if [[ "${daemonportread}" =~ ^[0-9]+$ ]] ; then daemonport=${daemonportread}; shift; fi;;
76 -stop) stopdaemon=1; shift ;;
77 -status) statusdaemon=1; shift ;;
79 -help) dohelp=1; shift;;
80 -D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
81 -X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
83 *) echo "Unknown option $1"; unknown_option=1; shift ;;
87 # Unknown Options and help
88 if [ "${unknown_option}" -eq 1 ]; then
92 if [ "${dohelp}" -eq 1 ]; then
97 if [[ "${debugport}" -lt 1024 ]] || [[ "${debugport}" -gt 65535 ]]; then
98 echo "Debug Port not in the range [1024,65535] ${debugport}"
102 # Validate daemon console port
103 if [[ "${daemonport}" -lt 1024 ]] || [[ "${daemonport}" -gt 65535 ]]; then
104 echo "Daemon console Port not in the range [1024,65535] value is ${daemonport}"
109 if [[ "${jmxport}" -lt 1024 ]] || [[ "${jmxport}" -gt 65535 ]]; then
110 echo "JMX Port not in the range [1024,65535] value is ${jmxport}"
115 if [ "${debugsuspend}" -eq 1 ]; then
116 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debugport}"
117 elif [ "${debug}" -eq 1 ]; then
118 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debugport}"
122 if [ "${startjmx}" -eq 1 ]; then
123 extraJVMOpts="${extraJVMOpts} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=${jmxport} -Dcom.sun.management.jmxremote"
126 ########################################
127 # Now add to classpath the OSGi JAR
128 ########################################
129 CLASSPATH=${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
130 FWCLASSPATH=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
132 ########################################
133 # Now add the extensions
134 ########################################
136 # Extension 1: this is used to be able to convert all the
137 # bundleresouce: URL in file: so packages that are not OSGi ready can
138 # still work. Notably this is the case for spring classes
139 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
140 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
142 ########################################
143 # Now add the launcher
144 ########################################
145 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
146 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
148 if [ "${stopdaemon}" -eq 1 ]; then
149 if [ -e "${pidfile}" ]; then
150 daemonpid=`cat "${pidfile}"`
153 echo "Controller with PID: ${daemonpid} -- Stopped!"
156 echo "Doesn't seem any Controller daemon is currently running"
161 if [ "${statusdaemon}" -eq 1 ]; then
162 if [ -e "${pidfile}" ]; then
163 daemonpid=`cat "${pidfile}"`
164 ps -p ${daemonpid} > /dev/null
166 if [ "${daemonexists}" -eq 0 ]; then
167 echo "Controller with PID: ${daemonpid} -- Running!"
170 echo "Controller with PID: ${daemonpid} -- Doesn't seem to exist"
175 echo "Doesn't seem any Controller daemon is currently running, at least no PID file has been found"
180 if [ "${startdaemon}" -eq 1 ]; then
181 if [ -e "${pidfile}" ]; then
182 echo "Another instance of controller running, check with $0 -status"
185 $JAVA_HOME/bin/java ${extraJVMOpts} \
186 -Djava.io.tmpdir=${basedir}/work/tmp \
187 -Dosgi.install.area=${basedir} \
188 -Dosgi.configuration.area=${basedir}/configuration \
189 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
190 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
191 -classpath ${CLASSPATH} \
192 org.eclipse.equinox.launcher.Main \
193 -console ${daemonport} \
196 echo ${daemonpid} > ${pidfile}
197 elif [ "${consolestart}" -eq 1 ]; then
198 if [ -e "${pidfile}" ]; then
199 echo "Another instance of controller running, check with $0 -status"
202 $JAVA_HOME/bin/java ${extraJVMOpts} \
203 -Djava.io.tmpdir=${basedir}/work/tmp \
204 -Dosgi.install.area=${basedir} \
205 -Dosgi.configuration.area=${basedir}/configuration \
206 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
207 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
208 -classpath ${CLASSPATH} \
209 org.eclipse.equinox.launcher.Main \