Advertisement
Guest User

Untitled

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