Hello,

The Karaf scripts have a mechanism to set KARAF_SCRIPT and then delegate
common config settings to setenv. The mechanism has however two quirks,
first of all if a script already sees a KARAF_SRIPT value it will not reset
it, and secondly it will use the PROGNAME of the script.

In default Karaf installation this seems to be not an issue, since the
condition on KARAF_SCRIPT in setenv is only a comment. However we do use
this mechanism to set settings for the main application server start and
for all other commands).

We check for KARAF_SCRIPT=start or KARAFAF_SCRIPT=karaf. However if rename
start to start2 or if I call it from another script which also sets
KARAF_SCRIPT in both cases the value passed to setenv is not "start" or
"karaf" and therefore it will pick the wrong settings.

I wonder if it would better to set the KARAF_SCRIPT settings
unconditionally in start and karaf. Not using PROGNAME would be another
option, nut sure if it is good or bad that a renamed script uses different
settings...?

A more general comment, a lot of environemnt variables used internal in the
scripts might be inherited from the current shell, that is somewhat a
support problem in our experience. Did you had a discussion on that,
already?

start:
https://github.com/apache/karaf/blob/25b1a00ab6b2330a469c244c4abc1389aaad5313/assemblies/features/base/src/main/filtered-resources/resources/bin/start#L71
if [ "x${KARAF_SCRIPT}" = "x" ]; then
KARAF_SCRIPT="${PROGNAME}"
export KARAF_SCRIPT
fi
if [ -f "${DIRNAME}/setenv" ]; then
. "${DIRNAME}/setenv"
fi

Reply via email to