3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
22 LINK=$(readlink "$(basename "$1")")
24 cd "$(dirname "$LINK")"
25 LINK=$(readlink "$(basename "$1")")
27 REALPATH="$PWD/$(basename "$1")"
32 REALNAME=$(realpath "$0")
33 DIRNAME=$(dirname "$REALNAME")
34 PROGNAME=$(basename "$REALNAME")
37 # Sourcing environment settings for karaf similar to tomcats setenv
41 if [ -f "$DIRNAME/setenv" ]; then
46 echo "${PROGNAME}: $*"
55 # OS specific support (must be 'true' or 'false').
74 # For AIX, set an environment variable
76 export LDR_CNTRL=MAXDATA=0xB0000000@DSA
82 if [ "x$KARAF_HOME" != "x" ]; then
83 warn "Ignoring predefined value for KARAF_HOME"
86 # In POSIX shells, CDPATH may cause cd to write to stdout
87 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
89 KARAF_HOME=`cd $DIRNAME/..; pwd`
90 if [ ! -d "$KARAF_HOME" ]; then
91 die "KARAF_HOME is not valid: $KARAF_HOME"
96 if [ "x$KARAF_BASE" != "x" ]; then
97 if [ ! -d "$KARAF_BASE" ]; then
98 die "KARAF_BASE is not valid: $KARAF_BASE"
101 KARAF_BASE=$KARAF_HOME
106 if [ "x$KARAF_DATA" != "x" ]; then
107 if [ ! -d "$KARAF_DATA" ]; then
108 die "KARAF_DATA is not valid: $KARAF_DATA"
111 KARAF_DATA=$KARAF_BASE/data
116 if [ "x$KARAF_ETC" != "x" ]; then
117 if [ ! -d "$KARAF_ETC" ]; then
118 die "KARAF_ETC is not valid: $KARAF_ETC"
121 KARAF_ETC=$KARAF_BASE/etc
126 # Determine if there is special OS handling we must perform
129 # Locate the Karaf home directory
132 # Locate the Karaf base directory
135 # Locate the Karaf data directory
138 # Locat the Karaf etc directory
144 KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
145 KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
146 KARAF_DATA=`cygpath --path --windows "$KARAF_DATA"`
147 KARAF_ETC=`cygpath --path --windows "$KARAF_ETC"`
148 if [ ! -z "$CLASSPATH" ]; then
149 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
152 # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
153 if [ ! -d "$KARAF_DATA/log" ]; then
154 mkdir -p "$KARAF_DATA/log"
156 exec "$KARAF_HOME"/bin/karaf stop "$@"