blob: dd6dfc2dda997b575e4c078f6cfd6bdb148b57b5 [file] [log] [blame]
Gert Vanthienen9bea2a32009-09-24 23:18:33 +00001#!/bin/sh
2#
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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.
17#
18# $Id: karaf 979 2005-11-30 22:50:55Z bsnyder $
19#
20
21DIRNAME=`dirname $0`
22PROGNAME=`basename $0`
23
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000024warn() {
25 echo "${PROGNAME}: $*"
26}
27
28die() {
29 warn "$*"
30 exit 1
31}
32
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000033detectOS() {
34 # OS specific support (must be 'true' or 'false').
35 cygwin=false;
36 darwin=false;
37 aix=false;
38 os400=false;
39 case "`uname`" in
40 CYGWIN*)
41 cygwin=true
42 ;;
43 Darwin*)
44 darwin=true
45 ;;
46 AIX*)
47 aix=true
48 ;;
49 OS400*)
50 os400=true
51 ;;
52 esac
53 # For AIX, set an environment variable
54 if $aix; then
55 export LDR_CNTRL=MAXDATA=0xB0000000@DSA
56 export IBM_JAVA_HEAPDUMP_TEXT=true
57 echo $LDR_CNTRL
58 fi
59}
60
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000061locateHome() {
62 if [ "x$KARAF_HOME" != "x" ]; then
63 warn "Ignoring predefined value for KARAF_HOME"
64 fi
65
66 # In POSIX shells, CDPATH may cause cd to write to stdout
67 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
68
69 KARAF_HOME=`cd $DIRNAME/..; pwd`
70 if [ ! -d "$KARAF_HOME" ]; then
71 die "KARAF_HOME is not valid: $KARAF_HOME"
72 fi
73}
74
75locateBase() {
76 if [ "x$KARAF_BASE" != "x" ]; then
77 if [ ! -d "$KARAF_BASE" ]; then
78 die "KARAF_BASE is not valid: $KARAF_BASE"
79 fi
80 else
81 KARAF_BASE=$KARAF_HOME
82 fi
83}
84
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000085init() {
86 # Determine if there is special OS handling we must perform
87 detectOS
88
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000089 # Locate the Karaf home directory
90 locateHome
91
92 # Locate the Karaf base directory
93 locateBase
Gert Vanthienen9bea2a32009-09-24 23:18:33 +000094}
95
96run() {
97 if $cygwin; then
98 KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
99 KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
100 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
101 fi
Guillaume Nodeta8163d22010-01-18 14:34:26 +0000102 # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
103 if [ ! -d "$KARAF_HOME/data/log" ]; then
104 mkdir -p "$KARAF_HOME/data/log"
105 fi
106 exec "$KARAF_HOME"/bin/karaf stop "$@"
Gert Vanthienen9bea2a32009-09-24 23:18:33 +0000107}
108
109main() {
110 init
111 run "$@"
112}
113
114main "$@"
Guillaume Nodeta8163d22010-01-18 14:34:26 +0000115