Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# Copyright 1999-2004 The Apache Software Foundation |
3 |
# |
4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
# you may not use this file except in compliance with the License. |
6 |
# You may obtain a copy of the License at |
7 |
# |
8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
9 |
# |
10 |
# Unless required by applicable law or agreed to in writing, software |
11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
# See the License for the specific language governing permissions and |
14 |
# limitations under the License. |
15 |
# |
16 |
# ----------------------------------------------------------------------------- |
17 |
# Cocoon Unix Shell Script |
18 |
# |
19 |
# $Id: cocoon.sh 389028 2006-03-27 06:21:40Z rgoers $ |
20 |
# ----------------------------------------------------------------------------- |
21 |
|
22 |
# Configuration variables |
23 |
# |
24 |
# COCOON_HOME |
25 |
# The root of the Cocoon distribution |
26 |
# |
27 |
# COCOON_WEBAPP_HOME |
28 |
# The root of the Cocoon web application |
29 |
# |
30 |
# COCOON_LIB |
31 |
# Folder containing all the library files needed by the Cocoon CLI |
32 |
# |
33 |
# JAVA_HOME |
34 |
# Home of Java installation. |
35 |
# |
36 |
# JAVA_OPTIONS |
37 |
# Extra options to pass to the JVM |
38 |
# |
39 |
# JAVA_DEBUG_ARGS |
40 |
# The command line arguments for the internal JVM debugger |
41 |
# |
42 |
# JAVA_PROFILE_ARGS |
43 |
# The command line arguments for the internal JVM profiler |
44 |
# |
45 |
# JETTY_PORT |
46 |
# Override the default port for Jetty |
47 |
# |
48 |
# JETTY_ADMIN_PORT |
49 |
# The port where the jetty web administration should bind |
50 |
# |
51 |
# LOADER_LIB |
52 |
# The classpath where to lookup the Loader class, defaults to |
53 |
# ${COCOON_HOME}/tools/loader |
54 |
# |
55 |
# CLI_CLASSPATH |
56 |
# The additional classpath for cli and precompile, defaults to |
57 |
# lib/core/servlet_2_2.jar:$COCOON_WEBAPP_HOME/WEB-INF/classes |
58 |
# |
59 |
|
60 |
|
61 |
usage() |
62 |
{ |
63 |
echo "Usage: $0 (action)" |
64 |
echo "actions:" |
65 |
echo " cli Run Cocoon from the command line" |
66 |
echo " precompile Crawl your webapp to compile all XSP files (requires the xsp block)" |
67 |
echo " servlet Run Cocoon in a servlet container (default)" |
68 |
echo " servlet-admin Run Cocoon in a servlet container and turn on container web administration" |
69 |
echo " servlet-debug Run Cocoon in a servlet container and turn on JVM remote debug" |
70 |
echo " servlet-profile Run Cocoon in a servlet container and turn on JVM profiling" |
71 |
exit 1 |
72 |
} |
73 |
|
74 |
# ----- Handle action parameter ------------------------------------------------ |
75 |
DEFAULT_ACTION="servlet" |
76 |
ACTION="$1" |
77 |
if [ -n "$ACTION" ] |
78 |
then |
79 |
shift |
80 |
else |
81 |
ACTION=$DEFAULT_ACTION |
82 |
echo "$0: executing default action '$ACTION', use -h to see other actions" |
83 |
fi |
84 |
ARGS="$*" |
85 |
|
86 |
# ----- Verify and Set Required Environment Variables ------------------------- |
87 |
|
88 |
if [ "$JAVA_HOME" = "" ] ; then |
89 |
JAVA_HOME="%%JAVA_HOME%%" |
90 |
fi |
91 |
|
92 |
if [ "$JAVA_OPTIONS" = "" ] ; then |
93 |
JAVA_OPTIONS='-Xms32M -Xmx512M -Dorg.apache.cocoon.settings=cocoon.properties' |
94 |
fi |
95 |
|
96 |
if [ "$COCOON_HOME" = "" ] ; then |
97 |
COCOON_HOME="%%APP_HOME%%" |
98 |
fi |
99 |
|
100 |
if [ "$COCOON_WEBAPP_HOME" = "" ] ; then |
101 |
STANDALONE_WEBAPP=../webapp |
102 |
if [ -d $STANDALONE_WEBAPP ] ; then |
103 |
# for standalone-webapp setup |
104 |
COCOON_WEBAPP_HOME=$STANDALONE_WEBAPP |
105 |
else |
106 |
# when in the build environment |
107 |
COCOON_WEBAPP_HOME="$COCOON_HOME/webapp" |
108 |
fi |
109 |
fi |
110 |
echo "$0: using $COCOON_WEBAPP_HOME as the webapp directory" |
111 |
|
112 |
if [ "$COCOON_LIB" = "" ] ; then |
113 |
COCOON_LIB="$COCOON_WEBAPP_HOME/WEB-INF/lib" |
114 |
fi |
115 |
|
116 |
if [ "$JETTY_PORT" = "" ] ; then |
117 |
JETTY_PORT='8888' |
118 |
fi |
119 |
|
120 |
if [ "$JETTY_ADMIN_PORT" = "" ] ; then |
121 |
JETTY_ADMIN_PORT='8889' |
122 |
fi |
123 |
|
124 |
if [ "$JAVA_DEBUG_ARGS" = "" ] ; then |
125 |
JAVA_DEBUG_ARGS='-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n' |
126 |
fi |
127 |
|
128 |
if [ "$JAVA_PROFILE_ARGS" = "" ] ; then |
129 |
JAVA_PROFILE_ARGS='-Xrunhprof:heap=all,cpu=samples,thread=y,depth=3' |
130 |
fi |
131 |
|
132 |
|
133 |
# ----- Set platform specific variables |
134 |
|
135 |
PATHSEP=":"; |
136 |
case "`uname`" in |
137 |
CYGWIN*) PATHSEP=";" |
138 |
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`;; |
139 |
esac |
140 |
|
141 |
# ----- Set Local Variables ( used to minimize cut/paste) --------------------- |
142 |
|
143 |
JAVA="exec $JAVA_HOME/bin/java" |
144 |
ENDORSED_LIBS="$COCOON_HOME/lib/endorsed" |
145 |
ENDORSED="-Djava.endorsed.dirs=$ENDORSED_LIBS" |
146 |
PARSER=-Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser |
147 |
LOADER=Loader |
148 |
if [ "$LOADER_LIB" = "" ] ; then |
149 |
LOADER_LIB="${COCOON_HOME}/tools/loader" |
150 |
fi |
151 |
|
152 |
CLI="-Dloader.main.class=org.apache.cocoon.Main" |
153 |
CLI_LIBRARIES="-Dloader.jar.repositories=$COCOON_LIB" |
154 |
if [ "$CLI_CLASSPATH" = "" ] ; then |
155 |
CLI_CLASSPATH="lib/core/servlet_2_2.jar:$COCOON_WEBAPP_HOME/WEB-INF/classes" |
156 |
fi |
157 |
CLI_VERBOSE="-Dloader.verbose=false" |
158 |
CLI_PROPERTIES="$CLI_LIBRARIES -Dloader.class.path=$CLI_CLASSPATH $CLI_VERBOSE" |
159 |
|
160 |
PRECOMPILE=-Dloader.main.class=org.apache.cocoon.bean.XSPPrecompileWrapper |
161 |
|
162 |
JETTY=-Dloader.main.class=org.mortbay.jetty.Server |
163 |
JETTY_CONF="$COCOON_HOME/tools/jetty/conf" |
164 |
JETTY_MAIN="$JETTY_CONF/main.xml" |
165 |
JETTY_ADMIN="$JETTY_CONF/admin.xml" |
166 |
JETTY_WEBAPP="-Dwebapp=$COCOON_WEBAPP_HOME" |
167 |
JETTY_HOME="-Dhome=$COCOON_HOME" |
168 |
JETTY_PORT_ARGS="-Djetty.port=$JETTY_PORT" |
169 |
JETTY_ADMIN_ARGS="-Djetty.admin.port=$JETTY_ADMIN_PORT" |
170 |
JETTY_LIBRARIES="-Dloader.jar.repositories=$COCOON_HOME/tools/jetty/lib${PATHSEP}${ENDORSED_LIBS}" |
171 |
|
172 |
# ----- Do the action ---------------------------------------------------------- |
173 |
|
174 |
case "$ACTION" in |
175 |
cli) |
176 |
$JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $CLI_PROPERTIES $CLI $LOADER $ARGS |
177 |
;; |
178 |
|
179 |
precompile) |
180 |
$JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $CLI_PROPERTIES $PRECOMPILE $LOADER $ARGS |
181 |
;; |
182 |
|
183 |
servlet) |
184 |
$JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN |
185 |
;; |
186 |
|
187 |
servlet-admin) |
188 |
$JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_ADMIN_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN $JETTY_ADMIN |
189 |
;; |
190 |
|
191 |
servlet-debug) |
192 |
$JAVA $JAVA_OPTIONS $JAVA_DEBUG_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN |
193 |
;; |
194 |
|
195 |
servlet-profile) |
196 |
$JAVA $JAVA_OPTIONS $JAVA_PROFILE_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN |
197 |
;; |
198 |
|
199 |
*) |
200 |
usage |
201 |
;; |
202 |
esac |
203 |
|
204 |
exit 0 |