|
Lines 1-145
Link Here
|
| 1 |
#!/bin/sh |
|
|
| 2 |
# |
| 3 |
# $FreeBSD: head/www/tomcat-devel/files/tomcat_devel.in 531294 2020-04-10 07:03:16Z fluffy $ |
| 4 |
# |
| 5 |
|
| 6 |
# PROVIDE: tomcat_devel |
| 7 |
# REQUIRE: LOGIN |
| 8 |
# KEYWORD: shutdown |
| 9 |
|
| 10 |
# |
| 11 |
# Configuration settings for tomcat_devel in /etc/rc.conf: |
| 12 |
# |
| 13 |
# tomcat_devel_enable (bool): |
| 14 |
# Set to "NO" by default. |
| 15 |
# Set it to "YES" to enable tomcat_devel |
| 16 |
# |
| 17 |
# tomcat_devel_catalina_home (str) |
| 18 |
# Set to "%%TOMCAT_HOME%%" by default. |
| 19 |
# Set the CATALINA_HOME variable for the Tomcat process |
| 20 |
# |
| 21 |
# tomcat_devel_catalina_base (str) |
| 22 |
# Set to "${catalina.home}" by default. |
| 23 |
# Set the CATALINA_BASE variable for the Tomcat process |
| 24 |
# |
| 25 |
# tomcat_devel_catalina_tmpdir (str) |
| 26 |
# Set to "${catalina.base}/temp" by default. |
| 27 |
# Set the CATALINA_TMPDIR variable for the Tomcat process |
| 28 |
# |
| 29 |
# tomcat_devel_stdout (str) |
| 30 |
# Set to "${catalina.base}/logs/catalina.out" by default. |
| 31 |
# Set the stdout redirection. It may also be '/dev/null', '&1' or '&2' |
| 32 |
# |
| 33 |
# tomcat_devel_stderr (str) |
| 34 |
# Set to "&1" by default. |
| 35 |
# Set the stderr redirection. It may also be '/dev/null', '&1' or '&2' |
| 36 |
# |
| 37 |
# tomcat_devel_pipe_cmd (str): |
| 38 |
# Set to "" by default. |
| 39 |
# Set a piped command to process stdout/stderr when passthru |
| 40 |
# |
| 41 |
# tomcat_devel_logging_manager (str): |
| 42 |
# Set to "org.apache.juli.ClassLoaderLogManager" by default. |
| 43 |
# Set the JUL log manager |
| 44 |
# |
| 45 |
# tomcat_devel_logging_config (str): |
| 46 |
# Set to "${catalina.base}/conf/logging.properties" by default. |
| 47 |
# Set the JUL config file |
| 48 |
# |
| 49 |
# tomcat_devel_java_home (str): |
| 50 |
# Set to "%%JAVA_HOME%%" by default. |
| 51 |
# Specify the Java VM to use. |
| 52 |
# |
| 53 |
# tomcat_devel_classpath (str): |
| 54 |
# Set to "" by default. |
| 55 |
# Addtional classes to add to the CLASSPATH. If set, must start with ':' |
| 56 |
# |
| 57 |
# tomcat_devel_java_opts (str): |
| 58 |
# Set to "" by default. |
| 59 |
# Java VM args to use. |
| 60 |
# |
| 61 |
# tomcat_devel_wait (int): |
| 62 |
# Set to "30" by default. |
| 63 |
# Set the wait time (in seconds) for Tomcat process startup |
| 64 |
# |
| 65 |
# tomcat_devel_umask (str): |
| 66 |
# Set to "0077" by default. |
| 67 |
# Sets the umask for Tomcat process. |
| 68 |
# |
| 69 |
# You may symlink this script with other names to run multiple |
| 70 |
# instances of tomcat_devel with different configurations. |
| 71 |
# |
| 72 |
|
| 73 |
. /etc/rc.subr |
| 74 |
|
| 75 |
case $0 in |
| 76 |
/etc/rc*) |
| 77 |
# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), |
| 78 |
# so get the name of the script from $_file |
| 79 |
name=$_file |
| 80 |
;; |
| 81 |
*) |
| 82 |
name=$0 |
| 83 |
;; |
| 84 |
esac |
| 85 |
|
| 86 |
name=${name##*/} |
| 87 |
rcvar=${name}_enable |
| 88 |
|
| 89 |
load_rc_config "${name}" |
| 90 |
|
| 91 |
eval "${rcvar}=\${${rcvar}:-'NO'}" |
| 92 |
eval "_tomcat_java_home=\${${name}_java_home:-'%%JAVA_HOME%%'}" |
| 93 |
eval "_tomcat_catalina_user=\${${name}_catalina_user:-'%%TOMCAT_USER%%'}" |
| 94 |
eval "_tomcat_catalina_home=\${${name}_catalina_home:-'%%TOMCAT_HOME%%'}" |
| 95 |
eval "_tomcat_catalina_base=\${${name}_catalina_base:-'${_tomcat_catalina_home}'}" |
| 96 |
eval "_tomcat_catalina_tmpdir=\${${name}_catalina_tmpdir:-'${_tomcat_catalina_base}/temp'}" |
| 97 |
eval "_tomcat_stdout=\${${name}_stdout:-'${_tomcat_catalina_base}/logs/catalina.out'}" |
| 98 |
eval "_tomcat_stderr=\${${name}_stderr:-'&1'}" |
| 99 |
eval "_tomcat_pipe_cmd=\${${name}_pipe_cmd:-''}" |
| 100 |
eval "_tomcat_logging_manager=\${${name}_logging_manager:-'org.apache.juli.ClassLoaderLogManager'}" |
| 101 |
eval "_tomcat_logging_config=\${${name}_logging_config:-'${_tomcat_catalina_base}/conf/logging.properties'}" |
| 102 |
eval "_tomcat_classpath=\${${name}_classpath:-''}" |
| 103 |
eval "_tomcat_java_opts=\${${name}_java_opts:-''}" |
| 104 |
eval "_tomcat_wait=\${${name}_wait:-'30'}" |
| 105 |
eval "_tomcat_umask=\${${name}_umask:-'0077'}" |
| 106 |
|
| 107 |
pidfile="/var/run/${name}.pid" |
| 108 |
|
| 109 |
required_files="${_tomcat_catalina_base}/conf/server.xml" |
| 110 |
required_dirs="${_tomcat_catalina_tmpdir}" |
| 111 |
|
| 112 |
extra_commands="reload" |
| 113 |
|
| 114 |
_tomcat_java_version=`${_tomcat_java_home}/bin/java -version 2>&1 | /usr/bin/awk -F '"' '/version/ {print $2}'` |
| 115 |
|
| 116 |
case "${_tomcat_java_version}" in |
| 117 |
9* | 1[0-9]* ) |
| 118 |
_tomcat_endorsed_dirs_option= |
| 119 |
;; |
| 120 |
*) |
| 121 |
_tomcat_endorsed_dirs_option="-Djava.endorsed.dirs='${_tomcat_catalina_home}/endorsed'" |
| 122 |
;; |
| 123 |
esac |
| 124 |
|
| 125 |
command="%%LOCALBASE%%/bin/jsvc" |
| 126 |
command_args="-java-home '${_tomcat_java_home}' \ |
| 127 |
-server \ |
| 128 |
-user ${_tomcat_catalina_user} \ |
| 129 |
-umask ${_tomcat_umask} \ |
| 130 |
-pidfile '${pidfile}' \ |
| 131 |
-wait ${_tomcat_wait} \ |
| 132 |
-outfile '${_tomcat_stdout}' \ |
| 133 |
-errfile '${_tomcat_stderr}' \ |
| 134 |
-classpath '${_tomcat_catalina_home}/bin/bootstrap.jar:%%LOCALBASE%%/share/java/classes/commons-daemon.jar:${_tomcat_catalina_home}/bin/tomcat-juli.jar${_tomcat_classpath}' \ |
| 135 |
-Djava.util.logging.manager=${_tomcat_logging_manager} \ |
| 136 |
-Djava.util.logging.config.file='${_tomcat_logging_config}' \ |
| 137 |
${_tomcat_java_opts} \ |
| 138 |
${_tomcat_endorsed_dirs_option} \ |
| 139 |
-Dcatalina.home='${_tomcat_catalina_home}' \ |
| 140 |
-Dcatalina.base='${_tomcat_catalina_base}' \ |
| 141 |
-Djava.io.tmpdir='${_tomcat_catalina_tmpdir}' \ |
| 142 |
org.apache.catalina.startup.Bootstrap \ |
| 143 |
${_tomcat_pipe_cmd}" |
| 144 |
|
| 145 |
run_rc_command "$1" |