When executing the karaf script, it gets the DIRNAME based on $0
which is the path used to start the script. This DIRNAME is then
used to set the KARAF_HOME and multiple other KARAF_* evn variables.
Using a symbolic link, you would have, for instance, usr/bin/karaf
redirecting to /opt/opendaylight/bin/karaf.
So $0 would be usr/bin and not /opt/opendaylight/bin so the locateHome
function isn't setting the right path for the KARAF_HOME.
This ends up failing to start ODL with following ERROR:
Error: Could not find or load main class org.apache.karaf.main.Main
see:
https://github.com/opendaylight/controller/blob/master/karaf/opendaylight-karaf-resources/src/main/resources/bin/karaf#l114l126
Change-Id: I36eff657972768de7d7b90f6563addfc3dd96c0f
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
Co-Authored-By: Michael Vorburger <vorburger@redhat.com>
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# limitations under the License.
#
# limitations under the License.
#
-DIRNAME=`dirname "$0"`
-PROGNAME=`basename "$0"`
+REALNAME=`readlink -e "$0"`
+if [ $? != 0 ]; then
+ REALNAME=$0
+fi
+DIRNAME=`dirname "$REALNAME"`
+PROGNAME=`basename "$REALNAME"`
#
# Sourcing environment settings for karaf similar to tomcats setenv
#
# Sourcing environment settings for karaf similar to tomcats setenv
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# limitations under the License.
#
# limitations under the License.
#
-DIRNAME=`dirname "$0"`
-PROGNAME=`basename "$0"`
+REALNAME=`readlink -e "$0"`
+if [ $? != 0 ]; then
+ REALNAME=$0
+fi
+DIRNAME=`dirname "$REALNAME"`
+PROGNAME=`basename "$REALNAME"`
#
# Sourcing environment settings for karaf similar to tomcats setenv
#
# Sourcing environment settings for karaf similar to tomcats setenv
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
- if [ "x$JAVA_HOME" = "x" ] && [ "$darwin" = "true" ]; then
- JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
- fi
+ if [ "x$JAVA_HOME" = "x" ] && [ "$darwin" = "true" ]; then
+ JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
+ fi
if [ "x$JAVA" = "x" ] && [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
if [ "x$JAVA" = "x" ] && [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi