solr-exporter 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. BASEDIR=`dirname $0`/..
  19. BASEDIR=`(cd "$BASEDIR"; pwd)`
  20. # OS specific support. $var _must_ be set to either true or false.
  21. cygwin=false;
  22. darwin=false;
  23. case "`uname`" in
  24. CYGWIN*) cygwin=true ;;
  25. Darwin*) darwin=true
  26. if [ -z "$JAVA_VERSION" ] ; then
  27. JAVA_VERSION="CurrentJDK"
  28. else
  29. echo "Using Java version: $JAVA_VERSION"
  30. fi
  31. if [ -z "$JAVA_HOME" ] ; then
  32. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
  33. fi
  34. ;;
  35. esac
  36. if [ -z "$JAVA_HOME" ] ; then
  37. if [ -r /etc/gentoo-release ] ; then
  38. JAVA_HOME=`java-config --jre-home`
  39. fi
  40. fi
  41. # For Cygwin, ensure paths are in UNIX format before anything is touched
  42. if $cygwin ; then
  43. [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  44. [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  45. fi
  46. # If a specific java binary isn't specified search for the standard 'java' binary
  47. if [ -z "$JAVACMD" ] ; then
  48. if [ -n "$JAVA_HOME" ] ; then
  49. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  50. # IBM's JDK on AIX uses strange locations for the executables
  51. JAVACMD="$JAVA_HOME/jre/sh/java"
  52. else
  53. JAVACMD="$JAVA_HOME/bin/java"
  54. fi
  55. else
  56. JAVACMD=`which java`
  57. fi
  58. fi
  59. if [ ! -x "$JAVACMD" ] ; then
  60. echo "Error: JAVA_HOME is not defined correctly."
  61. echo " We cannot execute $JAVACMD"
  62. exit 1
  63. fi
  64. if [ -z "$REPO" ]
  65. then
  66. REPO="$BASEDIR"/lib
  67. fi
  68. CLASSPATH=$CLASSPATH_PREFIX
  69. for JAR in $(find "$REPO" -name '*.jar')
  70. do
  71. CLASSPATH="$CLASSPATH":"$JAR"
  72. done
  73. for JAR in $(find "$BASEDIR"/../../dist/solrj-lib -name '*.jar')
  74. do
  75. CLASSPATH="$CLASSPATH":"$JAR"
  76. done
  77. for JAR in $(find "$BASEDIR"/../../dist -name 'solr-core-*.jar')
  78. do
  79. CLASSPATH="$CLASSPATH":"$JAR"
  80. done
  81. for JAR in $(find "$BASEDIR"/../../dist -name 'solr-solrj-*.jar')
  82. do
  83. CLASSPATH="$CLASSPATH":"$JAR"
  84. done
  85. for JAR in $(find "$BASEDIR"/../../dist -name 'solr-prometheus-exporter-*.jar')
  86. do
  87. CLASSPATH="$CLASSPATH":"$JAR"
  88. done
  89. for JAR in $(find "$BASEDIR"/lucene-libs -name '*.jar')
  90. do
  91. CLASSPATH="$CLASSPATH":"$JAR"
  92. done
  93. for JAR in $(find "$BASEDIR"/../../server/solr-webapp/webapp/WEB-INF/lib -name '*.jar')
  94. do
  95. CLASSPATH="$CLASSPATH":"$JAR"
  96. done
  97. EXTRA_JVM_ARGUMENTS="-Xmx512m -Dlog4j.configurationFile=file:"$BASEDIR"/../../server/resources/log4j2-console.xml"
  98. # For Cygwin, switch paths to Windows format before running java
  99. if $cygwin; then
  100. [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  101. [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
  102. [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
  103. [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
  104. [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
  105. fi
  106. exec "$JAVACMD" $JAVA_OPTS \
  107. $EXTRA_JVM_ARGUMENTS \
  108. -classpath "$CLASSPATH" \
  109. -Dapp.name="solr-exporter" \
  110. -Dapp.pid="$$" \
  111. -Dapp.repo="$REPO" \
  112. -Dbasedir="$BASEDIR" \
  113. org.apache.solr.prometheus.exporter.SolrExporter \
  114. "$@"