PageRenderTime 94ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/www-servers/tomcat/files/6/tomcat.init.3

http://github.com/funtoo/portage
Unknown | 123 lines | 108 code | 15 blank | 0 comment | 0 complexity | 644db62d022588117a2fb6163f0d0ffb MD5 | raw file
Possible License(s): Apache-2.0, AGPL-1.0, LGPL-2.1, MIT, CC-BY-SA-3.0, LGPL-2.0, Unlicense, AGPL-3.0, CC0-1.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, GPL-3.0
  1. #!/sbin/runscript
  2. # Copyright 1999-2011 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-x86/www-servers/tomcat/files/6/tomcat.init.3,v 1.3 2011/04/08 11:25:06 elvanor Exp $
  5. opts="${opts} forcestop"
  6. init_env_vars() {
  7. # Populate JAVA_HOME
  8. JAVA_HOME=`java-config --jre-home`
  9. # Set some sane defaults
  10. if [ -z "${CATALINA_TMPDIR}" ] ; then
  11. CATALINA_TMPDIR="${CATALINA_BASE}"/temp
  12. fi
  13. JPDA_TRANSPORT=${JPDA_TRANSPORT:="dt_socket"}
  14. JPDA_ADDRESS=${JPDA_ADDRESS:="8000"}
  15. JPDA_OPTS=${JPDA_OPTS="-Xdebug -Xrunjdwp:transport=${JPDA_TRANSPORT},address=${JPDA_ADDRESS},server=y,suspend=n"}
  16. # Activate Logging
  17. if [ -r "${CATALINA_HOME}"/bin/tomcat-juli.jar ]; then
  18. JAVA_OPTS="${JAVA_OPTS} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
  19. -Djava.util.logging.config.file=${CATALINA_BASE}/conf/logging.properties"
  20. fi
  21. # Populate the classpath
  22. unset CLASSPATH
  23. CLASSPATH="${CATALINA_HOME}/lib:${JAVA_HOME}/lib/tools.jar"
  24. if [ -n "${JSSE_HOME}" ]; then
  25. CLASSPATH="${CLASSPATH}:${JSSE_HOME}/lib/jcert.jar:${JSSE_HOME}/lib/jnet.jar:${JSSE_HOME}/lib/jsse.jar"
  26. fi
  27. CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar:${CATALINA_HOME}/bin/tomcat-juli.jar"
  28. OPTS_CP="${JAVA_OPTS} ${CATALINA_OPTS} -classpath ${CLASSPATH}"
  29. CATALINA_ARGS="-Dcatalina.base=${CATALINA_BASE} \
  30. -Dcatalina.home=${CATALINA_HOME} \
  31. -Djava.io.tmpdir=${CATALINA_TMPDIR} \
  32. org.apache.catalina.startup.Bootstrap "
  33. if [ ! -f "${CATALINA_BASE}logs/catalina.out" ]; then
  34. touch "${CATALINA_BASE}logs/catalina.out"
  35. chown "${CATALINA_USER}:${CATALINA_GROUP}" "${CATALINA_BASE}logs/catalina.out"
  36. fi
  37. }
  38. ssd() {
  39. local exec=${1}
  40. shift
  41. local args="--start --quiet \
  42. --chdir "${CATALINA_TMPDIR}" \
  43. --chuid ${CATALINA_USER}:${CATALINA_GROUP} \
  44. --make-pidfile --pidfile /var/run/tomcat-6.pid"
  45. # bug #243348
  46. if [ -e /etc/init.d/sysfs ] ; then
  47. args="${args} --background \
  48. --stdout ${CATALINA_BASE}/logs/catalina.out \
  49. --stderr ${CATALINA_BASE}/logs/catalina.out"
  50. start-stop-daemon ${args} --exec ${exec} -- ${OPTS_CP} "$@" ${CATALINA_ARGS} ${TOMCAT_START}
  51. else
  52. start-stop-daemon ${args} --name ${exec} --exec ${exec} -- ${OPTS_CP} "$@" ${CATALINA_ARGS} ${TOMCAT_START} >> \
  53. "${CATALINA_BASE}/logs/catalina.out" 2>&1 &
  54. fi
  55. return $?
  56. }
  57. depend() {
  58. use dns logger net
  59. }
  60. start() {
  61. ebegin "Starting Tomcat"
  62. init_env_vars
  63. if [ ! -e "${CATALINA_TMPDIR}" ]; then
  64. eerror "CATALINA_TMPDIR does not exist. Unable to start tomcat."
  65. eerror "Please see /etc/conf.d/tomcat-6 for more information."
  66. eend 1
  67. fi
  68. # Figure out what args to pass start_helper based on TOMCAT_START
  69. if [ "${TOMCAT_START}" = "debug" ] ; then
  70. ssd ${JAVA_HOME}/bin/jdb \
  71. -sourcepath ${CATALINA_HOME}/../../jakarta-tomcat-catalina/catalina/src/share
  72. elif [ "${TOMCAT_START}" = "-security debug" ] ; then
  73. ssd ${JAVA_HOME}/bin/jdb \
  74. -sourcepath ${CATALINA_HOME}/../../jakarta-tomcat-catalina/catalina/src/share \
  75. -Djava.security.manager \
  76. -Djava.security.policy=${CATALINA_BASE}/conf/catalina.policy
  77. elif [ "${TOMCAT_START}" = "jpda start" ] ; then
  78. ssd ${JAVA_HOME}/bin/java ${JPDA_OPTS}
  79. elif [ "${TOMCAT_START}" = "start" ] ; then
  80. ssd ${JAVA_HOME}/bin/java
  81. elif [ "${TOMCAT_START}" = "-security start" ] ; then
  82. ssd ${JAVA_HOME}/bin/java \
  83. -Djava.security.manager \
  84. -Djava.security.policy=${CATALINA_BASE}/conf/catalina.policy
  85. else
  86. eerror "Invalid TOMCAT_START variable value, or one is not set"
  87. eerror "Please see /etc/conf.d/tomcat-6 for more information"
  88. eend 1
  89. fi
  90. eend $?
  91. }
  92. stop() {
  93. ebegin "Stopping Tomcat"
  94. init_env_vars
  95. start-stop-daemon --stop --quiet --retry=60 \
  96. --pidfile /var/run/tomcat-6.pid \
  97. --exec ${JAVA_HOME}/bin/java -- ${OPTS_CP} ${CATALINA_args} stop ${STD_OUT}
  98. eend $?
  99. }
  100. forcestop() {
  101. ebegin "Forcing Tomcat to Stop"
  102. start-stop-daemon --stop --quiet --retry=60 \
  103. --pidfile /var/run/tomcat-6.pid --signal=9
  104. if service_started "${SVCNAME}"; then
  105. mark_service_stopped "${SVCNAME}"
  106. fi
  107. eend $?
  108. }