Advertisement
Guest User

catlina.sh

a guest
Aug 10th, 2012
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.30 KB | None | 0 0
  1. #!/bin/sh
  2. export JAVA_HOME=/usr/java/jdk1.6.0_24/
  3. export JRE_HOME=$JAVA_HOME
  4. export CATALINA_HOME=/home/rapidpas/appservers/apache-tomcat-6x/
  5. export JAVA_OPTS="-Xmx64000000 -Djava.awt.headless=true"
  6.  
  7. # -----------------------------------------------------------------------------
  8. # Start/Stop Script for the CATALINA Server
  9. #
  10. # Environment Variable Prequisites
  11. #
  12. # CATALINA_HOME May point at your Catalina "build" directory.
  13. #
  14. # CATALINA_BASE (Optional) Base directory for resolving dynamic portions
  15. # of a Catalina installation. If not present, resolves to
  16. # the same directory that CATALINA_HOME points to.
  17. #
  18. # CATALINA_OPTS (Optional) Java runtime options used when the "start",
  19. # "stop", or "run" command is executed.
  20. #
  21. # CATALINA_TMPDIR (Optional) Directory path location of temporary directory
  22. # the JVM should use (java.io.tmpdir). Defaults to
  23. # $CATALINA_BASE/temp.
  24. #
  25. # JAVA_HOME Must point at your Java Development Kit installation.
  26. # Required to run the with the "debug" or "javac" argument.
  27. #
  28. # JRE_HOME Must point at your Java Development Kit installation.
  29. # Defaults to JAVA_HOME if empty.
  30. #
  31. # JAVA_OPTS (Optional) Java runtime options used when the "start",
  32. # "stop", or "run" command is executed.
  33. #
  34. # JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start"
  35. # command is executed. The default is "dt_socket".
  36. #
  37. # JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start"
  38. # command is executed. The default is 8000.
  39. #
  40. # JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start"
  41. # command is executed. Specifies whether JVM should suspend
  42. # execution immediately after startup. Default is "n".
  43. #
  44. # JPDA_OPTS (Optional) Java runtime options used when the "jpda start"
  45. # command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,
  46. # and JPDA_SUSPEND are ignored. Thus, all required jpda
  47. # options MUST be specified. The default is:
  48. #
  49. # -Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,
  50. # address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND
  51. #
  52. # JSSE_HOME (Optional) May point at your Java Secure Sockets Extension
  53. # (JSSE) installation, whose JAR files will be added to the
  54. # system class path used to start Tomcat.
  55. #
  56. # CATALINA_PID (Optional) Path of the file which should contains the pid
  57. # of catalina startup java process, when start (fork) is used
  58. #
  59. # $Id: catalina.sh 500651 2007-01-27 22:45:06Z markt $
  60. # -----------------------------------------------------------------------------
  61.  
  62. # OS specific support. $var _must_ be set to either true or false.
  63. cygwin=false
  64. os400=false
  65. darwin=false
  66. case "`uname`" in
  67. CYGWIN*) cygwin=true;;
  68. OS400*) os400=true;;
  69. Darwin*) darwin=true;;
  70. esac
  71.  
  72. # resolve links - $0 may be a softlink
  73. PRG="$0"
  74.  
  75. while [ -h "$PRG" ]; do
  76. ls=`ls -ld "$PRG"`
  77. link=`expr "$ls" : '.*-> \(.*\)$'`
  78. if expr "$link" : '/.*' > /dev/null; then
  79. PRG="$link"
  80. else
  81. PRG=`dirname "$PRG"`/"$link"
  82. fi
  83. done
  84.  
  85. # Get standard environment variables
  86. PRGDIR=`dirname "$PRG"`
  87.  
  88. # Only set CATALINA_HOME if not already set
  89. [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." ; pwd`
  90.  
  91. if [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then
  92. . "$CATALINA_HOME"/bin/setenv.sh
  93. fi
  94.  
  95. # For Cygwin, ensure paths are in UNIX format before anything is touched
  96. if $cygwin; then
  97. [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  98. [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
  99. [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
  100. [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"`
  101. [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  102. [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --absolute --unix "$JSSE_HOME"`
  103. fi
  104.  
  105. # For OS400
  106. if $os400; then
  107. # Set job priority to standard for interactive (interactive - 6) by using
  108. # the interactive priority - 6, the helper threads that respond to requests
  109. # will be running at the same priority as interactive jobs.
  110. COMMAND='chgjob job('$JOBNAME') runpty(6)'
  111. system $COMMAND
  112.  
  113. # Enable multi threading
  114. export QIBM_MULTI_THREADED=Y
  115. fi
  116.  
  117. # Get standard Java environment variables
  118. if $os400; then
  119. # -r will Only work on the os400 if the files are:
  120. # 1. owned by the user
  121. # 2. owned by the PRIMARY group of the user
  122. # this will not work if the user belongs in secondary groups
  123. BASEDIR="$CATALINA_HOME"
  124. . "$CATALINA_HOME"/bin/setclasspath.sh
  125. else
  126. if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
  127. BASEDIR="$CATALINA_HOME"
  128. . "$CATALINA_HOME"/bin/setclasspath.sh
  129. else
  130. echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
  131. echo "This file is needed to run this program"
  132. exit 1
  133. fi
  134. fi
  135.  
  136. # Add on extra jar files to CLASSPATH
  137. if [ -n "$JSSE_HOME" ]; then
  138. CLASSPATH="$CLASSPATH":"$JSSE_HOME"/lib/jcert.jar:"$JSSE_HOME"/lib/jnet.jar:"$JSSE_HOME"/lib/jsse.jar
  139. fi
  140. CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar
  141.  
  142. if [ -z "$CATALINA_BASE" ] ; then
  143. CATALINA_BASE="$CATALINA_HOME"
  144. fi
  145.  
  146. if [ -z "$CATALINA_TMPDIR" ] ; then
  147. # Define the java.io.tmpdir to use for Catalina
  148. CATALINA_TMPDIR="$CATALINA_BASE"/temp
  149. fi
  150.  
  151. # Bugzilla 37848: When no TTY is available, don't output to console
  152. have_tty=0
  153. if [ "`tty`" != "not a tty" ]; then
  154. have_tty=1
  155. fi
  156.  
  157. # For Cygwin, switch paths to Windows format before running java
  158. if $cygwin; then
  159. JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
  160. JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
  161. CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
  162. CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"`
  163. CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"`
  164. CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  165. [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --absolute --windows "$JSSE_HOME"`
  166. JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
  167. fi
  168.  
  169. # Set juli LogManager if it is present
  170. if [ -r "$CATALINA_HOME"/conf/logging.properties ]; then
  171. JAVA_OPTS="$JAVA_OPTS "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" "-Djava.util.logging.config.file="$CATALINA_BASE/conf/logging.properties"
  172. fi
  173.  
  174. # ----- Execute The Requested Command -----------------------------------------
  175.  
  176. # Bugzilla 37848: only output this if we have a TTY
  177. if [ $have_tty -eq 1 ]; then
  178. echo "Using CATALINA_BASE: $CATALINA_BASE"
  179. echo "Using CATALINA_HOME: $CATALINA_HOME"
  180. echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
  181. if [ "$1" = "debug" -o "$1" = "javac" ] ; then
  182. echo "Using JAVA_HOME: $JAVA_HOME"
  183. else
  184. echo "Using JRE_HOME: $JRE_HOME"
  185. fi
  186. fi
  187.  
  188. if [ "$1" = "jpda" ] ; then
  189. if [ -z "$JPDA_TRANSPORT" ]; then
  190. JPDA_TRANSPORT="dt_socket"
  191. fi
  192. if [ -z "$JPDA_ADDRESS" ]; then
  193. JPDA_ADDRESS="8000"
  194. fi
  195. if [ -z "$JPDA_SUSPEND" ]; then
  196. JPDA_SUSPEND="n"
  197. fi
  198. if [ -z "$JPDA_OPTS" ]; then
  199. JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
  200. fi
  201. CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
  202. shift
  203. fi
  204.  
  205. if [ "$1" = "debug" ] ; then
  206. if $os400; then
  207. echo "Debug command not available on OS400"
  208. exit 1
  209. else
  210. shift
  211. if [ "$1" = "-security" ] ; then
  212. echo "Using Security Manager"
  213. shift
  214. exec "$_RUNJDB" $JAVA_OPTS $CATALINA_OPTS \
  215. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  216. -sourcepath "$CATALINA_HOME"/../../java \
  217. -Djava.security.manager \
  218. -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
  219. -Dcatalina.base="$CATALINA_BASE" \
  220. -Dcatalina.home="$CATALINA_HOME" \
  221. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  222. org.apache.catalina.startup.Bootstrap "$@" start
  223. else
  224. exec "$_RUNJDB" $JAVA_OPTS $CATALINA_OPTS \
  225. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  226. -sourcepath "$CATALINA_HOME"/../../java \
  227. -Dcatalina.base="$CATALINA_BASE" \
  228. -Dcatalina.home="$CATALINA_HOME" \
  229. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  230. org.apache.catalina.startup.Bootstrap "$@" start
  231. fi
  232. fi
  233.  
  234. elif [ "$1" = "run" ]; then
  235.  
  236. shift
  237. if [ "$1" = "-security" ] ; then
  238. echo "Using Security Manager"
  239. shift
  240. exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
  241. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  242. -Djava.security.manager \
  243. -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
  244. -Dcatalina.base="$CATALINA_BASE" \
  245. -Dcatalina.home="$CATALINA_HOME" \
  246. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  247. org.apache.catalina.startup.Bootstrap "$@" start
  248. else
  249. exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
  250. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  251. -Dcatalina.base="$CATALINA_BASE" \
  252. -Dcatalina.home="$CATALINA_HOME" \
  253. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  254. org.apache.catalina.startup.Bootstrap "$@" start
  255. fi
  256.  
  257. elif [ "$1" = "start" ] ; then
  258.  
  259. shift
  260. touch /home/rapidpas/appservers/apache-tomcat-6x/logs/stdout.log
  261. if [ "$1" = "-security" ] ; then
  262. echo "Using Security Manager"
  263. shift
  264. "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
  265. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  266. -Djava.security.manager \
  267. -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
  268. -Dcatalina.base="$CATALINA_BASE" \
  269. -Dcatalina.home="$CATALINA_HOME" \
  270. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  271. org.apache.catalina.startup.Bootstrap "$@" start \
  272. >> /home/rapidpas/appservers/apache-tomcat-6x/logs/stdout.log 2>&1 &
  273.  
  274. if [ ! -z "$CATALINA_PID" ]; then
  275. echo $! > $CATALINA_PID
  276. fi
  277. else
  278. "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
  279. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  280. -Dcatalina.base="$CATALINA_BASE" \
  281. -Dcatalina.home="$CATALINA_HOME" \
  282. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  283. org.apache.catalina.startup.Bootstrap "$@" start \
  284. >> /home/rapidpas/appservers/apache-tomcat-6x/logs/stdout.log 2>&1 &
  285.  
  286. if [ ! -z "$CATALINA_PID" ]; then
  287. echo $! > $CATALINA_PID
  288. fi
  289. fi
  290.  
  291. elif [ "$1" = "stop" ] ; then
  292.  
  293. shift
  294. FORCE=0
  295. if [ "$1" = "-force" ]; then
  296. shift
  297. FORCE=1
  298. fi
  299.  
  300. "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
  301. -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
  302. -Dcatalina.base="$CATALINA_BASE" \
  303. -Dcatalina.home="$CATALINA_HOME" \
  304. -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  305. org.apache.catalina.startup.Bootstrap "$@" stop
  306.  
  307. if [ $FORCE -eq 1 ]; then
  308. if [ ! -z "$CATALINA_PID" ]; then
  309. echo "Killing: `cat $CATALINA_PID`"
  310. kill -9 `cat $CATALINA_PID`
  311. else
  312. echo "Kill failed: \$CATALINA_PID not set"
  313. fi
  314. fi
  315.  
  316. elif [ "$1" = "version" ] ; then
  317.  
  318. "$_RUNJAVA" \
  319. -classpath "$CATALINA_HOME/lib/catalina.jar" \
  320. org.apache.catalina.util.ServerInfo
  321.  
  322. else
  323.  
  324. echo "Usage: catalina.sh ( commands ... )"
  325. echo "commands:"
  326. if $os400; then
  327. echo " debug Start Catalina in a debugger (not available on OS400)"
  328. echo " debug -security Debug Catalina with a security manager (not available on OS400)"
  329. else
  330. echo " debug Start Catalina in a debugger"
  331. echo " debug -security Debug Catalina with a security manager"
  332. fi
  333. echo " jpda start Start Catalina under JPDA debugger"
  334. echo " run Start Catalina in the current window"
  335. echo " run -security Start in the current window with security manager"
  336. echo " start Start Catalina in a separate window"
  337. echo " start -security Start in a separate window with security manager"
  338. echo " stop Stop Catalina"
  339. echo " stop -force Stop Catalina (followed by kill -KILL)"
  340. echo " version What version of tomcat are you running?"
  341. exit 1
  342.  
  343. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement