FELIX-1624: Add convenience start/stop scripts to run Karaf in the background
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@818654 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/assembly/src/main/distribution/unix-shell/bin/start b/karaf/assembly/src/main/distribution/unix-shell/bin/start
new file mode 100755
index 0000000..474885e
--- /dev/null
+++ b/karaf/assembly/src/main/distribution/unix-shell/bin/start
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# $Id: karaf 979 2005-11-30 22:50:55Z bsnyder $
+#
+
+DIRNAME=`dirname $0`
+PROGNAME=`basename $0`
+
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+die() {
+ warn "$*"
+ exit 1
+}
+
+detectOS() {
+ # OS specific support (must be 'true' or 'false').
+ cygwin=false;
+ darwin=false;
+ aix=false;
+ os400=false;
+ case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+ Darwin*)
+ darwin=true
+ ;;
+ AIX*)
+ aix=true
+ ;;
+ OS400*)
+ os400=true
+ ;;
+ esac
+ # For AIX, set an environment variable
+ if $aix; then
+ export LDR_CNTRL=MAXDATA=0xB0000000@DSA
+ export IBM_JAVA_HEAPDUMP_TEXT=true
+ echo $LDR_CNTRL
+ fi
+}
+
+locateHome() {
+ if [ "x$KARAF_HOME" != "x" ]; then
+ warn "Ignoring predefined value for KARAF_HOME"
+ fi
+
+ # In POSIX shells, CDPATH may cause cd to write to stdout
+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+ KARAF_HOME=`cd $DIRNAME/..; pwd`
+ if [ ! -d "$KARAF_HOME" ]; then
+ die "KARAF_HOME is not valid: $KARAF_HOME"
+ fi
+}
+
+locateBase() {
+ if [ "x$KARAF_BASE" != "x" ]; then
+ if [ ! -d "$KARAF_BASE" ]; then
+ die "KARAF_BASE is not valid: $KARAF_BASE"
+ fi
+ else
+ KARAF_BASE=$KARAF_HOME
+ fi
+}
+
+init() {
+ # Determine if there is special OS handling we must perform
+ detectOS
+
+ # Locate the Karaf home directory
+ locateHome
+
+ # Locate the Karaf base directory
+ locateBase
+}
+
+run() {
+ if $cygwin; then
+ KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
+ KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ fi
+ # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
+ if [ ! -d "$KARAF_HOME/data/log" ]; then
+ mkdir -p "$KARAF_HOME/data/log"
+ fi
+ exec "$KARAF_HOME"/bin/karaf server "$@" >> "$KARAF_HOME/data/log/karaf.out" 2>&1 &
+}
+
+main() {
+ init
+ run "$@"
+}
+
+main "$@"
+