/[gentoo-x86]/www-servers/tomcat/files/tomcat.init
Gentoo

Contents of /www-servers/tomcat/files/tomcat.init

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Jul 20 17:36:54 2012 UTC (7 years, 2 months ago) by sera
Branch: MAIN
Full rewrite.
Add tomcat-instance-manager.bash to convienintly create and remove multiple instances.
Don't symlink jars but use java-config as appropriate.
Migrate init script to baselayout2 including major cleanup.
Add use extra-webapps to build and install the docs and examples web apps. Use USE=doc for javadocs.
Major cleanup of the ebuild, like dropping elog massages obsolete for ages.
Don't copy manager and host-manager to catalina base but use a shared instance in catalina home which gets updated with a package
update.
Actually install sources if requested.
Initial Gentoo Prefix support.
#180519 : don kill ROOT application
#191611 : init script improvements
#254526 : emerge --config, implemented with tomcat-instance-manager.bash
#283273, #363931 : build docs and examples
#309211 : handling of manager / host-manager
#333153 : arbitrary classpath per instance
#381693 : init fails with non existent CATALINA_TMPDIR
#406285, #411597 : support multiple instances
#407979 : fails if /run is tmpfs
#420383 : forces invalid java compiler

(Portage version: 2.1.11.9/cvs/Linux x86_64)

1 #!/@GENTOO_PORTAGE_EPREFIX@sbin/runscript
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 extra_commands="forcestop"
6
7 PIDFILE=/@GENTOO_PORTAGE_EPREFIX@var/run/${RC_SVCNAME}.pid
8
9 : ${CATALINA_HOME:=/@GENTOO_PORTAGE_EPREFIX@usr/share/tomcat-@SLOT@}
10 : ${CATALINA_BASE:=/@GENTOO_PORTAGE_EPREFIX@var/lib/${RC_SVCNAME}}
11 : ${CATALINA_TMPDIR:=/@GENTOO_PORTAGE_EPREFIX@var/tmp/${RC_SVCNAME}}
12 : ${CATALINA_USER:=tomcat}
13 : ${CATALINA_GROUP:=tomcat}
14
15 : ${TOMCAT_START:=start}
16
17 : ${JPDA_TRANSPORT:="dt_socket"}
18 : ${JPDA_ADDRESS:="8000"}
19 : ${JPDA_OPTS="-Xdebug -Xrunjdwp:transport=${JPDA_TRANSPORT},address=${JPDA_ADDRESS},server=y,suspend=n"}
20
21 export JAVA_HOME=`java-config ${TOMCAT_JVM:+--select-vm ${TOMCAT_JVM}} --jre-home`
22
23 CLASSPATH=`java-config --classpath tomcat-@SLOT@${TOMCAT_EXTRA_JARS:+,${TOMCAT_EXTRA_JARS}}`
24 export CLASSPATH="${CLASSPATH}${TOMCAT_EXTRA_CLASSPATH:+:${TOMCAT_EXTRA_CLASSPATH}}"
25
26 depend() {
27 use dns logger net
28 }
29
30 start() {
31 ebegin "Starting ${RC_SVCNAME}"
32
33 if [ ! -e "${CATALINA_TMPDIR}" ]; then
34 eerror "CATALINA_TMPDIR does not exist. Unable to start tomcat."
35 eerror "Please see /@GENTOO_PORTAGE_EPREFIX@etc/conf.d/${RC_SVCNAME} for more information."
36 eend 1
37 fi
38
39 cmd=java args=
40 if [ "${TOMCAT_START}" = "debug" ] || [ "${TOMCAT_START}" = "-security debug" ] ; then
41 cmd=jdb
42 args="${args} -sourcepath ${CATALINA_HOME}/../../jakarta-tomcat-catalina/catalina/src/share"
43 fi
44 if [ "${TOMCAT_START}" = "-security debug" ] || [ "${TOMCAT_START}" = "-security start" ]; then
45 args="${args} -Djava.security.manager"
46 args="${args} -Djava.security.policy=${CATALINA_BASE}/conf/catalina.policy"
47 fi
48 if [ "${TOMCAT_START}" = "jpda start" ] ; then
49 args="${args} ${JPDA_OPTS}"
50 fi
51 if [ -r "${CATALINA_HOME}"/bin/tomcat-juli.jar ]; then
52 JAVA_OPTS="${JAVA_OPTS} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
53 -Djava.util.logging.config.file=${CATALINA_BASE}/conf/logging.properties"
54 fi
55
56 start-stop-daemon --start \
57 --quiet --background \
58 --chdir "${CATALINA_TMPDIR}" \
59 --user ${CATALINA_USER}:${CATALINA_GROUP} \
60 --make-pidfile --pidfile ${PIDFILE} \
61 --exec ${JAVA_HOME}/bin/${cmd} \
62 -- \
63 ${JAVA_OPTS} \
64 -Dcatalina.base="${CATALINA_BASE}" \
65 -Dcatalina.home="${CATALINA_HOME}" \
66 -Djava.io.tmpdir="${CATALINA_TMPDIR}" \
67 -classpath "${CLASSPATH}" \
68 org.apache.catalina.startup.Bootstrap \
69 ${CATALINA_OPTS} \
70 ${args} ${TOMCAT_START}
71
72 eend $?
73 }
74
75 stop() {
76 ebegin "Stopping '${RC_SVCNAME}'"
77
78 start-stop-daemon --stop \
79 --quiet --retry=60 \
80 --pidfile ${PIDFILE} \
81 --exec ${JAVA_HOME}/bin/java \
82 -- \
83 ${JAVA_OPTS} \
84 -classpath "${CLASSPATH}" \
85 ${CATALINA_OPTS} \
86 stop ${STD_OUT}
87
88 eend $?
89 }
90
91 forcestop() {
92 ebegin "Forcing '${RC_SVCNAME}' to stop"
93
94 start-stop-daemon --stop \
95 --quiet --retry=60 \
96 --pidfile ${PIDFILE} \
97 --signal=9
98
99 if service_started "${RC_SVCNAME}"; then
100 mark_service_stopped "${RC_SVCNAME}"
101 fi
102
103 eend $?
104 }

  ViewVC Help
Powered by ViewVC 1.1.20