Files

99 lines
2.6 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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
init() {
# KARAF-5332: Unset KARAF_DEBUG
unset KARAF_DEBUG
# Determine if there is special OS handling we must perform
detectOS
# Locate the Karaf home directory
locateHome
}
run() {
convertPaths
exec "${KARAF_HOME}/bin/karaf" stop "$@"
}
main() {
init
run "$@"
}
main "$@"