RSUpgradeJava.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #!/bin/sh
  2. ###Licensed Materials - Property of IBM
  3. ###
  4. ###IBM Cognos Products: rspecupgrade
  5. ###
  6. ###(C) Copyright IBM Corp. 2005, 2022
  7. ###
  8. ###US Government Users Restricted Rights - Use, duplication or disclosure
  9. ###restricted by GSA ADP Schedule Contract with IBM Corp.
  10. # Purpose
  11. # Set environment variables needed for Java and run a Java program.
  12. #
  13. # Arguments:
  14. # Parameters to the java command.
  15. #
  16. ###################################################################
  17. ###################################################################
  18. # Define the CLASSPATH separator character.
  19. # Would you believe that it is semicolon on Windows and colon on other platforms?
  20. sep=":"
  21. # Define exe extention for Windows executables
  22. exeExt=""
  23. # Define the path to the bundled JRE.
  24. ReportNetJRE=""
  25. platform="`uname -s`"
  26. case $platform in
  27. Windows*|CYGWIN*|MINGW*)
  28. sep=";"
  29. exeExt=".exe"
  30. if [ -z '../ibm-jre/jre' ]
  31. then
  32. ReportNetJRE=../ibm-jre/jre
  33. else
  34. ReportNetJRE=../jre
  35. fi
  36. # Replace the back slashes with forward slashes in the first parameter.
  37. # Otherwise the substring operations used to extract the filename (see v5queries variable) do not work properly.
  38. cleanv4path=`tr '\\' '/' << THEPATH
  39. ${1}
  40. THEPATH
  41. `
  42. ;;
  43. esac
  44. # Option to be used with JAVA_CMD when executing programs.
  45. # Can not be part of JAVA_CMD since JRE_HOME can have spaces
  46. # and JAVA_CMD must be one "word" if it is to be quoted.
  47. #
  48. # Use of the variable must not be in quotes otherwise an empty
  49. # string will be passed to java as a parameter.
  50. #
  51. # Value is either an empty string or "-classic"
  52. JAVA_OPTS=""
  53. if [ -z "$JRE_HOME" ]
  54. then
  55. if [ -z "$JAVA_HOME" ]
  56. then
  57. if [ -z "$ReportNetJRE" ]
  58. then
  59. echo
  60. else
  61. echo "Setting JRE_HOME to $ReportNetJRE"
  62. JRE_HOME="$ReportNetJRE"
  63. fi
  64. else
  65. echo "Setting JRE_HOME to value of JAVA_HOME: $JAVA_HOME"
  66. JRE_HOME="$JAVA_HOME"
  67. fi
  68. else
  69. echo "Using predefined JRE_HOME $JRE_HOME"
  70. fi
  71. if [ -z "$JRE_HOME" ]
  72. then
  73. echo "JRE_HOME is not defined. Please specify a valid JRE_HOME environment variable."
  74. exit 44
  75. fi
  76. echo "JRE_HOME=$JRE_HOME"
  77. JAVA_CMD="${JRE_HOME}/bin/java$exeExt"
  78. if [ -f "$JAVA_CMD" ]
  79. then
  80. echo "Using "$JAVA_CMD
  81. else
  82. echo "Cannot find $JAVA_CMD"
  83. exit 55
  84. fi
  85. CLASSPATH=".${sep}./jdxslt.jar${sep}./jaxen-1.1.1.jar${sep}${JRE_HOME}/lib/rt.jar${sep}./qfwV4toV5J.jar${sep}./cclcfgapi.jar${sep}./CognosIPF.jar${sep}./cclcoreutil.jar${sep}./log4j-api-2.17.1.jar${sep}./log4j-core-2.17.1.jar${sep}./log4j-over-slf4j-1.7.35.jar${sep}./slf4j-api-1.7.35.jar${sep}./icu4j.jar${sep}./dom4j-2.1.1.jar${sep}./jcam_crypto.jar${sep}./RSUpgrade.jar${sep}../webapps/p2pd/WEB-INF/lib/CognosCMPlugin.jar${sep}../webapps/p2pd/WEB-INF/lib/json4j.jar${sep}./jakarta-oro-2.0.8.jar${sep}./commons-lang-2.6.jar${sep}./commons-logging-1.1.jar${sep}./RSUpgradeTest.jar${sep}./i18nj.jar${sep}commons-httpclient-3.1.jar"
  86. # User defined classpath elements to add
  87. case $1 in
  88. -cp)
  89. shift
  90. CLASSPATH="$CLASSPATH${sep}${1}"
  91. shift
  92. ;;
  93. esac
  94. # The following case statement was copied from crconfig.sh
  95. # It would be better to have a single script that we all use to invoke Java.
  96. # I will propose this to the Java working group.
  97. case $platform in
  98. Linux)
  99. if [ -z "$LD_LIBRARY_PATH" ]
  100. then
  101. LD_LIBRARY_PATH=.
  102. else
  103. LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
  104. fi
  105. export LD_LIBRARY_PATH
  106. # Determine the Threading Model
  107. # getconf will return either linuxthreads-<version> or NPTL <version> depending on the threading model.
  108. getconf GNU_LIBPTHREAD_VERSION 2>&1 | grep NPTL > /dev/null 2>&1
  109. if [ $? -eq 0 ] ; then
  110. hasNPTL=true
  111. else
  112. hasNPTL=false
  113. fi
  114. if [ ${hasNPTL} = true ] ; then
  115. #
  116. # Linux Distribution supporting NPTL (Native POSIX Threads Library)
  117. # IBM JRE versions 1.4.1 and earlier do not support NPTL; required to use LinuxThreads
  118. # by setting LD_ASSUME_KERNEL=2.4.19
  119. #
  120. IBM_JRE_VERSION=`${JAVA_CMD} -version 2>&1 | sed -n 's/.*\([0-9]\.[0-9]*\.[0-9]*\)[ ]*IBM.*/\1/p'`
  121. useLinuxThreads=false
  122. case ${IBM_JRE_VERSION:=0} in
  123. 1.4.*)
  124. IBM_JRE_REVISION=`echo ${IBM_JRE_VERSION} | sed -n 's/1\.[0-9]*\.\([0-9]*\)/\1/p'`
  125. if [ ${IBM_JRE_REVISION} -lt 2 ] ; then
  126. useLinuxThreads=true
  127. fi
  128. ;;
  129. 1.3.*)
  130. useLinuxThreads=true
  131. ;;
  132. esac
  133. if [ ${useLinuxThreads} = true ] ; then
  134. LD_ASSUME_KERNEL=2.4.19
  135. export LD_ASSUME_KERNEL
  136. fi
  137. fi
  138. ;;
  139. SunOS)
  140. if [ -z "$LD_LIBRARY_PATH" ]
  141. then
  142. LD_LIBRARY_PATH=.
  143. else
  144. LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
  145. fi
  146. export LD_LIBRARY_PATH
  147. ;;
  148. AIX)
  149. if [ -z "$LIBPATH" ]
  150. then
  151. LIBPATH=.
  152. else
  153. LIBPATH=".:$LIBPATH"
  154. fi
  155. export LIBPATH
  156. JAVA_OPTS="-Xmx512345678"
  157. ;;
  158. HP-UX)
  159. if [ -z "$SHLIB_PATH" ]
  160. then
  161. SHLIB_PATH=.
  162. else
  163. SHLIB_PATH=".:$SHLIB_PATH"
  164. fi
  165. export SHLIB_PATH
  166. if [ "$LC_CTYPE" = "ja_JP.utf8" ]
  167. then
  168. JAVA_CMD="$JRE_HOME/bin/java"
  169. export JAVA_CMD
  170. JAVA_OPTS="-classic"
  171. else if [ "$LANG" = "ja_JP.utf8" ]
  172. then
  173. JAVA_CMD="$JRE_HOME/bin/java"
  174. export JAVA_CMD
  175. JAVA_OPTS="-classic"
  176. fi
  177. fi
  178. JAVA_OPTS="$JAVA_OPTS -Xmx512345678"
  179. ;;
  180. OS/390)
  181. if [ "$LIBPATH" = "" ]
  182. then
  183. LIBPATH=.
  184. else
  185. LIBPATH=".:$LIBPATH"
  186. fi
  187. export LIBPATH
  188. IBM_JAVA_OPTIONS="-Dfile.encoding=ISO8859-1 -Xnoargsconversion"
  189. export IBM_JAVA_OPTIONS
  190. IBM_JAVA_ENABLE_ASCII_FILETAG="ON"
  191. export IBM_JAVA_ENABLE_ASCII_FILETAG
  192. ;;
  193. Windows*|CYGWIN*|MINGW*)
  194. ;;
  195. *)
  196. echo ""
  197. echo "Unexpected platform: $platform"
  198. echo ""
  199. ;;
  200. esac
  201. echo $*
  202. echo "$JAVA_CMD" ${JAVA_OPTS} -cp "$CLASSPATH" $*
  203. "$JAVA_CMD" ${JAVA_OPTS} -cp "$CLASSPATH" $*
  204. exit $?