summaryrefslogtreecommitdiffstats
path: root/test/servlet-containers/karaf/karaf-run/apache-karaf-4.2.1-minimal/bin/shell
blob: a89bedc6aea0df083a57832e8996e099be0200ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/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.
#

realpath() {
  # Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
  AWK=awk
  if ${solaris}; then
      if [ -x /usr/xpg4/bin/awk ]; then
          AWK=/usr/xpg4/bin/awk
      elif [ -x /usr/bin/nawk ]; then
          AWK=/usr/bin/nawk
      fi
  fi

  READLINK_EXISTS=$(command -v readlink &> /dev/null)
  if [ -z "$READLINK_EXISTS" ]; then
    OURPWD=${PWD}
    cd "$(dirname "${1}")" || exit 2
    LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
    while [ "${LINK}" ]; do
        echo "link: ${LINK}" >&2
        cd "$(dirname "${LINK}")" || exit 2
        LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
    done
    REALPATH="${PWD}/$(basename "${1}")"
    cd "${OURPWD}" || exit 2
    echo "${REALPATH}"
  else
    OURPWD=${PWD}
    cd "$(dirname "${1}")" || exit 2
    LINK=$(readlink "$(basename "${1}")")
    while [ "${LINK}" ]; do
            echo "link: ${LINK}" >&2
        cd "$(dirname "${LINK}")" || exit 2
        LINK=$(readlink "$(basename "${1}")")
    done
    REALPATH="${PWD}/$(basename "${1}")"
    cd "${OURPWD}" || exit 2
    echo "${REALPATH}"
  fi
}

REALNAME=$(realpath "$0")
DIRNAME=$(dirname "${REALNAME}")
PROGNAME=$(basename "${REALNAME}")

#
# Load common functions
#
. "${DIRNAME}/inc"

#
# Sourcing environment settings for karaf similar to tomcats setenv
#
KARAF_SCRIPT="${PROGNAME}"
export KARAF_SCRIPT
if [ -f "${DIRNAME}/setenv" ]; then
  . "${DIRNAME}/setenv"
fi

setupClassPath() {
    # Setup classpath
    CLASSPATH="${KARAF_HOME}/system/org/apache/karaf/shell/org.apache.karaf.shell.core/4.2.1/org.apache.karaf.shell.core-4.2.1.jar"
    CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/ops4j/pax/logging/pax-logging-api/1.10.1/pax-logging-api-1.10.1.jar"
    CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/jline/jline/3.9.0/jline-3.9.0.jar"
}

init() {
    # Determine if there is special OS handling we must perform
    detectOS

    # Unlimit the number of file descriptors if possible
    unlimitFD

    # Locate the Karaf home directory
    locateHome

    # Locate the Karaf base directory
    locateBase

    # Locate the Karaf data directory
    locateData

    # Locate the Karaf etc directory
    locateEtc

    # Setup the native library path
    setupNativePath

    # Locate the Java VM to execute
    locateJava

    # Determine the JVM vendor
    detectJVM

    # Setup default options
    setupDefaults

    # Setup classpath
    setupClassPath

    # Install debug options
    setupDebugOptions
}

run() {
    convertPaths
    exec "${JAVA}" ${JAVA_OPTS} \
        -Dkaraf.instances="${KARAF_HOME}/instances" \
        -Dkaraf.home="${KARAF_HOME}" \
        -Dkaraf.base="${KARAF_BASE}" \
        -Dkaraf.etc="${KARAF_ETC}" \
        -Dkaraf.data="${KARAF_DATA}" \
        -Djava.io.tmpdir="${KARAF_DATA}/tmp" \
        -Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
        ${KARAF_OPTS} \
        ${OPTS} \
        -classpath "${CLASSPATH}" \
        org.apache.karaf.shell.impl.console.standalone.Main --classpath="$KARAF_HOME/system" "$@"
}

main() {
    init
    run "$@"
}

main "$@"