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 [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
48 pidfile="${TMP}/opendaylight.PID"
50 pidfile="/tmp/opendaylight.PID"
67 -debug) debug=1; shift ;;
68 -debugsuspend) debugsuspend=1; shift ;;
69 -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;;
70 -start) startdaemon=1; shift; daemonportread="$1"; if [[ "${daemonportread}" =~ ^[0-9]+$ ]] ; then daemonport=${daemonportread}; shift; fi;;
71 -stop) stopdaemon=1; shift ;;
72 -status) statusdaemon=1; shift ;;
74 -help) dohelp=1; shift;;
75 -D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
76 -X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
78 *) echo "Unknown option $1"; unknown_option=1; shift ;;
82 # Unknown Options and help
83 if [ "${unknown_option}" -eq 1 ]; then
87 if [ "${dohelp}" -eq 1 ]; then
92 if [[ "${debugport}" -lt 1024 ]] || [[ "${debugport}" -gt 65535 ]]; then
93 echo "Debug Port not in the range [1024,65535] ${debugport}"
97 # Validate daemon console port
98 if [[ "${daemonport}" -lt 1024 ]] || [[ "${daemonport}" -gt 65535 ]]; then
99 echo "Daemon console Port not in the range [1024,65535] value is ${daemonport}"
104 if [ "${debugsuspend}" -eq 1 ]; then
105 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debugport}"
106 elif [ "${debug}" -eq 1 ]; then
107 extraJVMOpts="${extraJVMOpts} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debugport}"
110 ########################################
111 # Now add to classpath the OSGi JAR
112 ########################################
113 CLASSPATH=${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
114 FWCLASSPATH=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar
116 ########################################
117 # Now add the extensions
118 ########################################
120 # Extension 1: this is used to be able to convert all the
121 # bundleresouce: URL in file: so packages that are not OSGi ready can
122 # still work. Notably this is the case for spring classes
123 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
124 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar
126 ########################################
127 # Now add the launcher
128 ########################################
129 CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
130 FWCLASSPATH=${FWCLASSPATH},file:${basedir}/lib/org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar
132 if [ "${stopdaemon}" -eq 1 ]; then
133 if [ -e "${pidfile}" ]; then
134 daemonpid=`cat "${pidfile}"`
137 echo "Controller with PID: ${daemonpid} -- Stopped!"
140 echo "Doesn't seem any Controller daemon is currently running"
145 if [ "${statusdaemon}" -eq 1 ]; then
146 if [ -e "${pidfile}" ]; then
147 daemonpid=`cat "${pidfile}"`
148 ps -p ${daemonpid} > /dev/null
150 if [ "${daemonexists}" -eq 0 ]; then
151 echo "Controller with PID: ${daemonpid} -- Running!"
154 echo "Controller with PID: ${daemonpid} -- Doesn't seem to exist"
159 echo "Doesn't seem any Controller daemon is currently running, at least no PID file has been found"
164 if [ "${startdaemon}" -eq 1 ]; then
165 if [ -e "${pidfile}" ]; then
166 echo "Another instance of controller running, check with $0 -status"
169 $JAVA_HOME/bin/java ${extraJVMOpts} \
170 -Djava.io.tmpdir=${basedir}/work/tmp \
171 -Dosgi.install.area=${basedir} \
172 -Dosgi.configuration.area=${basedir}/configuration \
173 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
174 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
175 -classpath ${CLASSPATH} \
176 org.eclipse.equinox.launcher.Main \
177 -console ${daemonport} \
180 echo ${daemonpid} > ${pidfile}
181 elif [ "${consolestart}" -eq 1 ]; then
182 if [ -e "${pidfile}" ]; then
183 echo "Another instance of controller running, check with $0 -status"
186 $JAVA_HOME/bin/java ${extraJVMOpts} \
187 -Djava.io.tmpdir=${basedir}/work/tmp \
188 -Dosgi.install.area=${basedir} \
189 -Dosgi.configuration.area=${basedir}/configuration \
190 -Dosgi.frameworkClassPath=${FWCLASSPATH} \
191 -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
192 -classpath ${CLASSPATH} \
193 org.eclipse.equinox.launcher.Main \