zkEnv.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # This script should be sourced into other zookeeper
  17. # scripts to setup the env variables
  18. # We use ZOOCFGDIR if defined,
  19. # otherwise we use /etc/zookeeper
  20. # or the conf directory that is
  21. # a sibling of this script's directory
  22. ZOOBINDIR=${ZOOBINDIR:-/usr/bin}
  23. ZOOKEEPER_PREFIX=${ZOOBINDIR}/..
  24. if [ "x$ZOOCFGDIR" = "x" ]
  25. then
  26. if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then
  27. ZOOCFGDIR="$ZOOBINDIR/../conf"
  28. else
  29. ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper"
  30. fi
  31. fi
  32. if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
  33. . "${ZOOCFGDIR}/zookeeper-env.sh"
  34. fi
  35. if [ "x$ZOOCFG" = "x" ]
  36. then
  37. ZOOCFG="zoo.cfg"
  38. fi
  39. ZOOCFG="$ZOOCFGDIR/$ZOOCFG"
  40. if [ -f "$ZOOCFGDIR/java.env" ]
  41. then
  42. . "$ZOOCFGDIR/java.env"
  43. fi
  44. if [ "x${ZOO_LOG_DIR}" = "x" ]
  45. then
  46. ZOO_LOG_DIR="."
  47. fi
  48. if [ "x${ZOO_LOG4J_PROP}" = "x" ]
  49. then
  50. ZOO_LOG4J_PROP="INFO,CONSOLE"
  51. fi
  52. if [ "$JAVA_HOME" != "" ]; then
  53. JAVA="$JAVA_HOME/bin/java"
  54. else
  55. JAVA=java
  56. fi
  57. #add the zoocfg dir to classpath
  58. CLASSPATH="$ZOOCFGDIR:$CLASSPATH"
  59. for i in "$ZOOBINDIR"/../src/java/lib/*.jar
  60. do
  61. CLASSPATH="$i:$CLASSPATH"
  62. done
  63. #make it work in the release
  64. if [ -d ${ZOOKEEPER_PREFIX}/share/zookeeper ]; then
  65. LIBPATH="${ZOOKEEPER_PREFIX}"/share/zookeeper/*.jar
  66. else
  67. LIBPATH="${ZOOBINDIR}"/../lib/*.jar
  68. fi
  69. for i in ${LIBPATH}
  70. do
  71. CLASSPATH="$i:$CLASSPATH"
  72. done
  73. #make it work for developers
  74. for d in "$ZOOBINDIR"/../build/lib/*.jar
  75. do
  76. CLASSPATH="$d:$CLASSPATH"
  77. done
  78. #make it work for developers
  79. CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH"
  80. case "`uname`" in
  81. CYGWIN*) cygwin=true ;;
  82. *) cygwin=false ;;
  83. esac
  84. if $cygwin
  85. then
  86. CLASSPATH=`cygpath -wp "$CLASSPATH"`
  87. fi
  88. #echo "CLASSPATH=$CLASSPATH"