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;
9 if [[ "$unamestr" == 'Linux' ]]; then
11 elif [[ "$unamestr" == 'Darwin' ]]; then
15 if [[ $platform == 'linux' ]]; then
16 fullpath=`readlink -f $0`
17 elif [[ $platform == 'osx' ]]; then
19 cd `dirname $TARGET_FILE`
20 TARGET_FILE=`basename $TARGET_FILE`
22 # Iterate down a (possible) chain of symlinks
23 while [ -L "$TARGET_FILE" ]
25 TARGET_FILE=`readlink $TARGET_FILE`
26 cd `dirname $TARGET_FILE`
27 TARGET_FILE=`basename $TARGET_FILE`
30 # Compute the canonicalized name by finding the physical path
31 # for the directory we're in and appending the target file.
33 RESULT=$PHYS_DIR/$TARGET_FILE
37 basedir=`dirname ${fullpath}`
40 echo "Usage: $0 [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
45 pidfile="${TMP}/opendaylight.PID"
47 pidfile="/tmp/opendaylight.PID"
64 -debug) debug=1; shift ;;
65 -debugsuspend) debugsuspend=1; shift ;;
66 -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;;
67 -start) startdaemon=1; shift; daemonportread="$1"; if [[ "${daemonportread}" =~ ^[0-9]+$ ]] ; then daemonport=${daemonportread}; shift; fi;;
68 -stop) stopdaemon=1; shift ;;
69 -status) statusdaemon=1; shift ;;
71 -help) dohelp=1; shift;;
72 -D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
73 -X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
75 *) echo "Unknown option $1"; unknown_option=1; shift ;;
79 # Unknown Options and help
80 if [ "${unknown_option}" -eq 1 ]; then
84 if [ "${dohelp}" -eq 1 ]; then
89 if [[ "${debugport}" -lt 1024 ]] || [[ "${debugport}" -gt 65535 ]]; then
90 echo "Debug Port not in the range [1024,65535] ${debugport}"
94 # Validate daemon console port
95 if [[ "${daemonport}" -lt 1024 ]] || [[ "${daemonport}" -gt 65535 ]]; then
96 echo "Daemon console Port not in the range [1024,65535] value is ${daemonport}"
101 if [ "${debugsuspend}" -eq 1 ]; then
102 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debugport}"
103 elif [ "${debug}" -eq 1 ]; then
104 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debugport}"
107 ########################################
108 # Now add to classpath the OSGi JAR
109 ########################################
110 CLASSPATH=${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
111 FWCLASSPATH=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
113 ########################################
114 # Now add the extensions
115 ########################################
117 # Extension 1: this is used to be able to convert all the
118 # bundleresouce: URL in file: so packages that are not OSGi ready can
119 # still work. Notably this is the case for spring classes
120 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
121 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
123 ########################################
124 # Now add the launcher
125 ########################################
126 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
127 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
129 if [ "${stopdaemon}" -eq 1 ]; then
130 if [ -e "${pidfile}" ]; then
131 daemonpid=`cat "${pidfile}"`
134 echo "Controller with PID: ${daemonpid} -- Stopped!"
137 echo "Doesn't seem any Controller daemon is currently running"
142 if [ "${statusdaemon}" -eq 1 ]; then
143 if [ -e "${pidfile}" ]; then
144 daemonpid=`cat "${pidfile}"`
145 ps -p ${daemonpid} > /dev/null
147 if [ "${daemonexists}" -eq 0 ]; then
148 echo "Controller with PID: ${daemonpid} -- Running!"
151 echo "Controller with PID: ${daemonpid} -- Doesn't seem to exist"
156 echo "Doesn't seem any Controller daemon is currently running, at least no PID file has been found"
161 if [ "${startdaemon}" -eq 1 ]; then
162 if [ -e "${pidfile}" ]; then
163 echo "Another instance of controller running, check with $0 -status"
166 $JAVA_HOME/bin/java ${extraJVMOpts} \
167 -Djava.io.tmpdir=${basedir}/work/tmp \
168 -Dosgi.install.area=${basedir} \
169 -Dosgi.configuration.area=${basedir}/configuration \
170 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
171 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
172 -classpath ${CLASSPATH} \
173 org.eclipse.equinox.launcher.Main \
174 -console ${daemonport} \
177 echo ${daemonpid} > ${pidfile}
178 elif [ "${consolestart}" -eq 1 ]; then
179 if [ -e "${pidfile}" ]; then
180 echo "Another instance of controller running, check with $0 -status"
183 $JAVA_HOME/bin/java ${extraJVMOpts} \
184 -Djava.io.tmpdir=${basedir}/work/tmp \
185 -Dosgi.install.area=${basedir} \
186 -Dosgi.configuration.area=${basedir}/configuration \
187 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
188 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
189 -classpath ${CLASSPATH} \
190 org.eclipse.equinox.launcher.Main \