You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/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. realpath() {
  19. # Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
  20. AWK=awk
  21. if ${solaris}; then
  22. if [ -x /usr/xpg4/bin/awk ]; then
  23. AWK=/usr/xpg4/bin/awk
  24. elif [ -x /usr/bin/nawk ]; then
  25. AWK=/usr/bin/nawk
  26. fi
  27. fi
  28. READLINK_EXISTS=$(command -v readlink &> /dev/null)
  29. if [ -z "$READLINK_EXISTS" ]; then
  30. OURPWD=${PWD}
  31. cd "$(dirname "${1}")" || exit 2
  32. LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
  33. while [ "${LINK}" ]; do
  34. echo "link: ${LINK}" >&2
  35. cd "$(dirname "${LINK}")" || exit 2
  36. LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
  37. done
  38. REALPATH="${PWD}/$(basename "${1}")"
  39. cd "${OURPWD}" || exit 2
  40. echo "${REALPATH}"
  41. else
  42. OURPWD=${PWD}
  43. cd "$(dirname "${1}")" || exit 2
  44. LINK=$(readlink "$(basename "${1}")")
  45. while [ "${LINK}" ]; do
  46. echo "link: ${LINK}" >&2
  47. cd "$(dirname "${LINK}")" || exit 2
  48. LINK=$(readlink "$(basename "${1}")")
  49. done
  50. REALPATH="${PWD}/$(basename "${1}")"
  51. cd "${OURPWD}" || exit 2
  52. echo "${REALPATH}"
  53. fi
  54. }
  55. REALNAME=$(realpath "$0")
  56. DIRNAME=$(dirname "${REALNAME}")
  57. PROGNAME=$(basename "${REALNAME}")
  58. #
  59. # Load common functions
  60. #
  61. . "${DIRNAME}/inc"
  62. #
  63. # Sourcing environment settings for karaf similar to tomcats setenv
  64. #
  65. KARAF_SCRIPT="${PROGNAME}"
  66. export KARAF_SCRIPT
  67. if [ -f "${DIRNAME}/setenv" ]; then
  68. . "${DIRNAME}/setenv"
  69. fi
  70. init() {
  71. # KARAF-5332: Unset KARAF_DEBUG
  72. unset KARAF_DEBUG
  73. # Determine if there is special OS handling we must perform
  74. detectOS
  75. # Locate the Karaf home directory
  76. locateHome
  77. }
  78. run() {
  79. convertPaths
  80. exec "${KARAF_HOME}/bin/karaf" status "$@"
  81. }
  82. main() {
  83. init
  84. run "$@"
  85. }
  86. main "$@"