Advertisement
Guest User

Untitled

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