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.

client 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. setupClassPath() {
  71. # Add the jars in the lib dir
  72. CLASSPATH="${KARAF_HOME}/system/org/apache/karaf/org.apache.karaf.client/4.2.1/org.apache.karaf.client-4.2.1.jar"
  73. CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/apache/sshd/sshd-core/1.7.0/sshd-core-1.7.0.jar"
  74. CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/fusesource/jansi/jansi/1.17.1/jansi-1.17.1.jar"
  75. CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/jline/jline/3.9.0/jline-3.9.0.jar"
  76. CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar"
  77. }
  78. init() {
  79. # Determine if there is special OS handling we must perform
  80. detectOS
  81. # Unlimit the number of file descriptors if possible
  82. unlimitFD
  83. # Locate the Karaf home directory
  84. locateHome
  85. # Locate the Karaf base directory
  86. locateBase
  87. # Locate the Karaf data directory
  88. locateData
  89. # Locate the Karaf etc directory
  90. locateEtc
  91. # Setup the native library path
  92. setupNativePath
  93. # Locate the Java VM to execute
  94. locateJava
  95. # Determine the JVM vendor
  96. detectJVM
  97. # Setup default options
  98. setupDefaults
  99. # Setup classpath
  100. setupClassPath
  101. }
  102. run() {
  103. convertPaths
  104. exec "${JAVA}" ${JAVA_OPTS} \
  105. -Dkaraf.instances="${KARAF_HOME}/instances" \
  106. -Dkaraf.home="${KARAF_HOME}" \
  107. -Dkaraf.base="${KARAF_BASE}" \
  108. -Dkaraf.etc="${KARAF_ETC}" \
  109. -Djava.io.tmpdir="${KARAF_DATA}/tmp" \
  110. -Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
  111. ${KARAF_OPTS} ${OPTS} \
  112. -classpath "${CLASSPATH}" \
  113. org.apache.karaf.client.Main "$@"
  114. }
  115. main() {
  116. init
  117. run "$@"
  118. }
  119. main "$@"