Add env vars to set the controller working directory. 74/2174/2
authorSam Hague <shague@redhat.com>
Fri, 25 Oct 2013 18:00:10 +0000 (14:00 -0400)
committerSam Hague <shague@redhat.com>
Fri, 25 Oct 2013 21:46:19 +0000 (17:46 -0400)
The run.sh makes an assumption that the current working directory is
writeable and owned by the user running the command. These assumptions
don't hold when running the controller as a service such as when it
was installed via an RPM package.

Added two env variables to specify the run directory and the output
directory:

ODL_BASEDIR: working directory
ODL_DATADIR: output directory

By default the run.sh will continue to use the current working directory
and will only use the env vars if they are set.

Change-Id: I85dda38353f632e84409d91ac4dfc4a44c2d457e
Signed-off-by: Sam Hague <shague@redhat.com>
opendaylight/distribution/opendaylight/src/main/resources/run.sh

index e4c20da..b34e8f7 100755 (executable)
@@ -46,7 +46,17 @@ fi
 [[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
 JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
 
-basedir=`dirname ${fullpath}`
+if [ -z ${ODL_BASEDIR} ]; then
+    basedir=`dirname ${fullpath}`
+else
+    basedir=${ODL_BASEDIR}
+fi
+
+if [ -z ${ODL_DATADIR} ]; then
+    datadir=`dirname ${fullpath}`
+else
+    datadir=${ODL_DATADIR}
+fi
 
 function usage {
     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>]"
@@ -192,9 +202,9 @@ if [ "${startdaemon}" -eq 1 ]; then
         exit -1
     fi
     $JAVA_HOME/bin/java ${extraJVMOpts} \
-        -Djava.io.tmpdir=${basedir}/work/tmp \
+        -Djava.io.tmpdir=${datadir}/work/tmp \
         -Dosgi.install.area=${basedir} \
-        -Dosgi.configuration.area=${basedir}/configuration \
+        -Dosgi.configuration.area=${datadir}/configuration \
         -Dosgi.frameworkClassPath=${FWCLASSPATH} \
         -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
         -classpath ${CLASSPATH} \
@@ -209,9 +219,9 @@ elif [ "${consolestart}" -eq 1 ]; then
         exit -1
     fi
     $JAVA_HOME/bin/java ${extraJVMOpts} \
-        -Djava.io.tmpdir=${basedir}/work/tmp \
+        -Djava.io.tmpdir=${datadir}/work/tmp \
         -Dosgi.install.area=${basedir} \
-        -Dosgi.configuration.area=${basedir}/configuration \
+        -Dosgi.configuration.area=${datadir}/configuration \
         -Dosgi.frameworkClassPath=${FWCLASSPATH} \
         -Dosgi.framework=file:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
         -classpath ${CLASSPATH} \