Advertisement
Guest User

Untitled

a guest
Oct 9th, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.42 KB | None | 0 0
  1. export UGII_BASE_DIR=/usr/ugs060 ; export UGII_BASE_DIR
  2. export UGII_ROOT_DIR=/usr/ugs060/bin/ ; export UGII_ROOT_DIR
  3. export UGS_LICENSE_SERVER=28000@blackbox ; export UGS_LICENSE_SERVER
  4. export LD_LIBRARY_PATH=/usr/ugs060/bin/
  5.  
  6. #!/bin/ksh
  7. # *****************************************************************************
  8. # Copyright (c) 1994-2008 UGS. All rights reserved
  9. # SCCS: @(#) link_stamp ugii V6.0.0.24 06/18/08 18:41:58
  10. # *****************************************************************************
  11. # Title: ugii
  12. # Purpose: Shell script to start NX.
  13. # *****************************************************************************
  14. # Rev History:
  15. # 6.0 Ric Baxter 31JUL07 Initial NX 6.0 version taken directly from NX 5.0.
  16. # 6.0 Ric Baxter 20MAY08 Final NX6 version.
  17. # *****************************************************************************
  18. # Script Description:
  19. # This script will start Unigraphics NX on the following workstations:
  20. # AIX|HP-UX|Linux|SunOS
  21. # The operation of the script is briefly described by the following:
  22. # 1. Set and or check all the prerequisite environment.
  23. # 2. Check for optional Java runtime environment.
  24. # 3. Determine if Space Ball should be started.
  25. # 4. Check if X is running then start Unigraphics NX [and spaceball].
  26. # *****************************************************************************
  27.  
  28. # *****************************************************************************
  29. # GLOBAL VARIABLES ************************************************************
  30. # *****************************************************************************
  31.  
  32. # Unset any aliases to preclued colisions.
  33. unalias $(alias | cut -d= -f1 | grep ^[0-z]) 2>/dev/null # Added for AIX V160P03
  34.  
  35. # PRE-REQUISITE ENVIRONMENT VARS. ____________________________________________
  36. : ${DISPLAY:?variable must be set to run ugii} # Ck DISPLAY var.
  37. : ${UGS_LICENSE_SERVER:?variable must be set to run UG} # Ck UGS_LICENSE_SERVER.
  38. # Check UGII_ROOT_DIR is set AND that it is real. # Ck UGII_ROOT_DIR.
  39. [ -d "${UGII_ROOT_DIR:?variable must be set to run ugii}" ] || {
  40. echo "ugii: \$UGII_ROOT_DIR is not a directory." ; sleep 2 ; exit 1 ; }
  41. : ${UGII_BASE_DIR:=`dirname $UGII_ROOT_DIR`} # BASE_DIR from ROOT_DIR.
  42. BASE=$UGII_BASE_DIR # Shortened name.
  43. export UGII_BASE_DIR UGII_ROOT_DIR # export em.
  44.  
  45. # GENERAL SCRIPT VARS. _______________________________________________________
  46. CMD_LINE_ARGS=$@ # Save cmd line args.
  47. HOST=`uname -n` # Get the hostname.
  48. ERR="\n\rERROR:\t" # Error messages.
  49. WARN="\n\rWARNING: " # Warning messages.
  50. MSG="\n\t" # Normal text.
  51. NU=/dev/null # Linux cuz cant use 1>&-
  52. #
  53. # To skip the ug_validate test, set this variable to non-zero.
  54. : ${RUN_UG_VALIDATE:=1} # Default to off - don't run ug_validate. V190P04
  55. #
  56. # Directory containing the UG Shared Libraries.
  57. UGLIBS=$BASE/ugii # Rm uglibs dir V2.0P06
  58. UGRAF_IMAGE=ugraf # Default name of ugraf image. NX4P20.
  59.  
  60.  
  61. # PLATFORM SPECIFIC VARS. ____________________________________________________
  62. case `uname` in # Set system dependent variables
  63. AIX) # IBM platform.
  64. export PATH=.:/usr/bin:/usr/sbin:/usr/ucb:/bin:/usr/bin/X11:/sbin:$PATH
  65. X11_DIR=/usr/bin/X11 # X11 directory for this system.
  66. #
  67. # Set the LIBPATH, for the UG shared libraries.
  68. if [ -z "$LIBPATH" ] ; then # It's NOT set so set it.
  69. LIBPATH=/usr/lib:$UGLIBS
  70. else # It was set. Check it & prepend UGLIBS if not found.
  71. echo $LIBPATH | grep "$UGLIBS" 1>$NU 2>$NU || {
  72. LIBPATH=$UGLIBS:$LIBPATH ;}
  73. fi
  74. #
  75. # JAVA specific env vars for AIX. Added NX4P20.
  76. # On AIX we only need to set LIBPATH.
  77. #
  78. # Check the env first, then if needed call env_print to read .ugii_env file.
  79. # AIX splits it's libraries into 2 dirs so both dirs need to be used.
  80. # UGII_JVM_LIBRARY_DIR & UGII_JVM_LIBRARY_DIR2 should contain the platform
  81. # specific Java runtime libs.
  82. : ${UGII_JVM_LIBRARY_DIR:=$(
  83. $BASE/ugii/env_print UGII_JVM_LIBRARY_DIR 2>$NU) }
  84. : ${UGII_JVM_LIBRARY_DIR2:=$(
  85. $BASE/ugii/env_print UGII_JVM_LIBRARY_DIR2 2>$NU) }
  86. #
  87. # Check that UGII_JVM_LIBRARY_DIR and UGII_JVM_LIBRARY_DIR2 are both valid
  88. # dirs then add them to LIBPATH. NX4P23
  89. # Tweak -d test to rm quotes. AIX Ksh fails w/quotes. NX5P25a.
  90. [ -d ${UGII_JVM_LIBRARY_DIR} -a -d ${UGII_JVM_LIBRARY_DIR2} ] && {
  91. # On IBM we need to ck LIBPATH for both of these dirs.
  92. #
  93. # Check for UGII_JVM_LIBRARY_DIR if not there prepend it. Chngd NX4P23
  94. echo $LIBPATH | tr ':' '\012' | \
  95. grep "^${UGII_JVM_LIBRARY_DIR}$" 1>$NU 2>$NU || {
  96. LIBPATH=${UGII_JVM_LIBRARY_DIR}:$LIBPATH
  97. }
  98. #
  99. # Check for UGII_JVM_LIBRARY_DIR2 if not there prepend it. Added NX4P23
  100. echo $LIBPATH | tr ':' '\012' | \
  101. grep "^${UGII_JVM_LIBRARY_DIR2}$" 1>$NU 2>$NU || {
  102. LIBPATH=${UGII_JVM_LIBRARY_DIR2}:$LIBPATH
  103. }
  104. #
  105. # Change the name of the ugraf image to ugraf_java.
  106. UGRAF_IMAGE=ugraf_java
  107. }
  108. #
  109. # NX 5.0.1.4 AIX Ksh bug adds a space to concatenated strings like LIBPATH
  110. # add workaround to remove spurious spaces from LIBPATH.
  111. LIBPATH=$(echo $LIBPATH | sed s'! !!g') # Remove spaces.
  112. export LIBPATH
  113. ;;
  114. HP-UX) # HP platform.
  115. export PATH=.:/bin:/usr/bin:/etc:/usr/contrib/bin:/usr/local/bin:$PATH
  116. X11_DIR=/usr/bin/X11 # X11 directory for this system.
  117. #
  118. # Set LD_LIBRARY_PATH for HPR shared libs. Changed from SHLIB_PATH V190P01.
  119. if [ -z "$LD_LIBRARY_PATH" ] ; then # It's NOT set so set it.
  120. LD_LIBRARY_PATH=/usr/lib:$UGLIBS
  121. else # It was set. Check it & prepend UGLIBS if not found.
  122. echo $LD_LIBRARY_PATH | grep "$UGLIBS" 1>$NU 2>$NU || {
  123. LD_LIBRARY_PATH=$UGLIBS:$LD_LIBRARY_PATH ;}
  124. fi
  125. #
  126. # JAVA specific env vars for HPR. Added NX4P20.
  127. # On HPR we need to set LD_PRELOAD_ONCE var.
  128. #
  129. # Check the env first, then if needed call env_print to read .ugii_env file.
  130. # UGII_JVM_LIBRARY_DIR should contain platform specific Java runtime libs.
  131. : ${UGII_JVM_LIBRARY_DIR:=`$BASE/ugii/env_print UGII_JVM_LIBRARY_DIR 2>$NU`}
  132. # UGII_JSIG_LIB is an explicit list of Java signal handler(s).
  133. : ${UGII_JSIG_LIB:=$($BASE/ugii/env_print UGII_JSIG_LIB 2>$NU)}
  134. #
  135. # Added NX050P19. More HP Specific libraries.
  136. # UGII_JAVA_RUNTIME_LIBDIR ensures that all java libraries are able to be
  137. # demand loaded to ensure proper program execution. e.g, the swing libs.
  138. : ${UGII_JAVA_RUNTIME_LIBDIR:=$(
  139. $BASE/ugii/env_print UGII_JAVA_RUNTIME_LIBDIR 2>$NU )}
  140. # Make sure it got set, and it really exists, then append to library path.
  141. [ -n "$UGII_JAVA_RUNTIME_LIBDIR" -a -d "$UGII_JAVA_RUNTIME_LIBDIR" ] && {
  142. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$UGII_JAVA_RUNTIME_LIBDIR"
  143. }
  144. #
  145. # Check that UGII_JVM_LIBRARY_DIR is a valid dir AND that UGII_JSIG_LIB
  146. # is a valid list of file(s). Only first file is checked.
  147. [ -d "${UGII_JVM_LIBRARY_DIR}" ] && [ -r "${UGII_JSIG_LIB%%:*}" ] && {
  148. # Sanity check both vars even if both vars are not actually used.
  149. # Check if the PRELOAD var is set. Then prepend to it or just set it.
  150. if [ "$LD_PRELOAD_ONCE" ] ; then # Already set so prepend to it.
  151. LD_PRELOAD_ONCE="${UGII_JSIG_LIB}:$LD_PRELOAD_ONCE"
  152. else # Not set so just set it.
  153. LD_PRELOAD_ONCE=$UGII_JSIG_LIB
  154. fi
  155. }
  156. #
  157. export LD_LIBRARY_PATH LD_PRELOAD_ONCE
  158. ;;
  159. Linux) # Linux Wed Apr 13 17:19:36 PDT 2005
  160. alias -x echo="print" # Linux echo cant do esc chars.
  161. export PATH=.:/bin:/usr/bin:/usr/sbin:/usr/contrib/bin:${PATH}
  162. #
  163. X11_DIR=/usr/bin/X11 # Directory for X11 executables.
  164. #
  165. # Temporary setting for early Linux phases.
  166. export LC_CTYPE=C
  167. #
  168. # Set LD_LIBRARY_PATH for Linux shared libs.
  169. if [ -z "$LD_LIBRARY_PATH" ] ; then # It's NOT set so set it.
  170. LD_LIBRARY_PATH=/usr/lib:$UGLIBS
  171. else # It was set. Check it & prepend UGLIBS if not found.
  172. echo $LD_LIBRARY_PATH | grep "$UGLIBS" 1>$NU 2>$NU || {
  173. LD_LIBRARY_PATH=$UGLIBS:$LD_LIBRARY_PATH ;}
  174. fi
  175. #
  176. # JAVA specific env vars for Linux. Added NX4P20.
  177. # On Linux set both LD_LIBRARY_PATH and LD_PRELOAD.
  178. #
  179. # Check the env first, then if needed call env_print to read .ugii_env file.
  180. # UGII_JVM_LIBRARY_DIR and UGII_JVM_LIBRARY_DIR2 should contain platform
  181. # specific Java runtime libs.
  182. [ "${UGII_JVM_LIBRARY_DIR2}" ] || { # If not set in env call env_print.
  183. UGII_JVM_LIBRARY_DIR2=$($BASE/ugii/env_print UGII_JVM_LIBRARY_DIR2 2>$NU)
  184. }
  185. # UGII_JSIG_LIB is an explicit list of Java signal handler(s).
  186. : ${UGII_JSIG_LIB:=$($BASE/ugii/env_print UGII_JSIG_LIB 2>$NU)}
  187. #
  188. # Check that UGII_JVM_LIBRARY_DIR2 is a valid dir AND that UGII_JSIG_LIB
  189. # is a valid list of file(s). Only first file is checked.
  190. [ -d "${UGII_JVM_LIBRARY_DIR2}" ] && [ -r "${UGII_JSIG_LIB%%:*}" ] && {
  191. # Linux splits its libs into a dir & a subdir. It needs the parent dir
  192. # (UGII_JVM_LIBRARY_DIR2) added to the LD_LIBRARY_PATH. Added NX4P22
  193. # UGII_JVM_LIBRARY_DIR still needs to be set but is not added to
  194. # to the LD_LIBRARY_PATH. NX4P22.
  195. # Check LD_LIBRARY_PATH for UGII_JVM_LIBRARY_DIR2 if not there prepend it.
  196. echo $LD_LIBRARY_PATH | grep "$UGII_JVM_LIBRARY_DIR2" 1>$NU 2>$NU || {
  197. LD_LIBRARY_PATH=${UGII_JVM_LIBRARY_DIR2}:$LD_LIBRARY_PATH
  198. }
  199. # Check if PRELOAD var is set. Then prepend to it or just set it.
  200. if [ "$LD_PRELOAD" ] ; then # Already set so prepend to it.
  201. LD_PRELOAD="${UGII_JSIG_LIB}:$LD_PRELOAD"
  202. else # Not set so just set it.
  203. LD_PRELOAD=$UGII_JSIG_LIB
  204. fi
  205. }
  206. #
  207. export LD_LIBRARY_PATH LD_PRELOAD
  208. ;;
  209. SunOS) # Sun platform.
  210. export PATH=.:/sbin:/usr/sbin:/usr/bin:/bin:/etc:$PATH
  211. X11_DIR=/usr/openwin/bin # X11 directory for this system.
  212. #
  213. # Sun specific keyboard variable.
  214. [ "${UGII_KEYBOARD_TYPE}" ] || {
  215. case `uname -m` in # Workaround for broken "kbd" command
  216. sun4c) export UGII_KEYBOARD_TYPE="sun_model4" ;; # sparc2/ipx
  217. sun4m|*) export UGII_KEYBOARD_TYPE="sun_model5" ;; # sparc10 or future.
  218. esac
  219. }
  220. # Special workaround to prempt conflicts with new SUN 64 Bit LIB PATH var.
  221. unset LD_LIBRARY_PATH_64 # V190P21.
  222. #
  223. # Set the LD_LIBRARY_PATH, for the UG shared libraries.
  224. if [ -z "$LD_LIBRARY_PATH" ] ; then # It's NOT set so set it.
  225. LD_LIBRARY_PATH=/usr/lib:$UGLIBS
  226. else # It was set. Check it & prepend UGLIBS if not found.
  227. echo $LD_LIBRARY_PATH | grep "$UGLIBS" 1>$NU 2>$NU || {
  228. LD_LIBRARY_PATH=$UGLIBS:$LD_LIBRARY_PATH ;}
  229. fi
  230. #
  231.  
  232. # JAVA specific env vars for SUN. Added NX4P20.
  233. # On SUN we only need to set LD_PRELOAD_64.
  234. #
  235. # Check the env first, then if needed call env_print to read .ugii_env file.
  236. # UGII_JVM_LIBRARY_DIR should contain platform specific Java runtime libs.
  237. : ${UGII_JVM_LIBRARY_DIR:=`$BASE/ugii/env_print UGII_JVM_LIBRARY_DIR 2>$NU`}
  238. # UGII_JSIG_LIB is an explicit list of Java signal handler(s).
  239. : ${UGII_JSIG_LIB:=$($BASE/ugii/env_print UGII_JSIG_LIB 2>$NU)}
  240. #
  241. # Check that UGII_JVM_LIBRARY_DIR is a valid dir AND that UGII_JSIG_LIB
  242. # is a valid list of file(s). Only first file is checked.
  243. [ -d "${UGII_JVM_LIBRARY_DIR}" ] && [ -r "${UGII_JSIG_LIB%%:*}" ] && {
  244. # Sanity check both vars even if both vars are not actually used.
  245. # Check if the PRELOAD var is set. Then prepend to it or just set it.
  246. if [ "$LD_PRELOAD_64" ] ; then # Its set so prepend.
  247. LD_PRELOAD_64="${UGII_JSIG_LIB}:$LD_PRELOAD_64"
  248. else # Not set so just set it.
  249. LD_PRELOAD_64=$UGII_JSIG_LIB
  250. fi
  251. }
  252. #
  253. export LD_LIBRARY_PATH LD_PRELOAD_64
  254. ;;
  255. *) echo "${ERR}`uname` not supported by this script." >&2 ; exit 5
  256. ;;
  257. esac
  258.  
  259.  
  260. # *****************************************************************************
  261. # FUNCTION DEFINITIONS ********************************************************
  262. # *****************************************************************************
  263.  
  264.  
  265. Run_ug_validate() # Run the ug_validate program to check customer defaults.
  266. { # RKB Mar 3 13:58 95 V105P01
  267. # Run ug_validate it hasn't been turned off with the flag.
  268. [ "${RUN_UG_VALIDATE}" = 0 ] || return 0 # Turned off so return.
  269. # Make sure ug_validate is there and executable.
  270. [ -x ${UGII_BASE_DIR}/ugii/ug_validate ] || {
  271. echo "${ERR}${UGII_BASE_DIR}/ugii/ug_validate not found, or not executable
  272. \n\t\tPress <Return> to continue \c"
  273. read CR ; return 1
  274. }
  275. # Check unigraphics definition file.
  276. ${UGII_BASE_DIR}/ugii/ug_validate 1>$NU 2>$NU || {
  277. echo "${ERR}NX definitions file defined by the variable
  278. \r\tUGII_DEFAULTS_FILE in the '.ugii_env' file did NOT pass validation.
  279. \r\tCorrect this file and verify using: 'ug_validate' or 'ugmenu'.
  280. \n\t\tPress <Return> to continue \c"
  281. read CR ; return 1
  282. }
  283. return 0
  284. } # End Run_ug_validate.
  285.  
  286.  
  287. # *****************************************************************************
  288. # MAIN ************************************************************************
  289. # *****************************************************************************
  290.  
  291. # Runtime checks. _____________________________________________________________
  292.  
  293. # Check that we have X running.
  294. ${X11_DIR}/xset -q 1>$NU 2>$NU || { # Error if Xm window not running..
  295. echo "${ERR}unable to start NX.
  296. \r\tCheck: X windows is running, $DISPLAY is valid,
  297. \r\tand X display has been authorized on ${DISPLAY}.
  298. \n\t\tPress <Return> to continue \c" ; read CR
  299. exit 1
  300. }
  301.  
  302. # Check that the ugraf image is there and executable.
  303. [ -x ${UGII_BASE_DIR}/ugii/$UGRAF_IMAGE ] || {
  304. echo "${ERR} ugraf was not found, or was not executable
  305. \n\t\tPress <Return> to continue \c" ; read CR ; exit 1
  306. }
  307.  
  308. # Run ug_validate it hasn't been turned off with the flag.
  309. [ "${RUN_UG_VALIDATE}" = 0 ] && { Run_ug_validate || exit 1 ;}
  310.  
  311.  
  312. # Final startup. _____________________________________________________________
  313.  
  314. # Give a starup message.
  315. echo "\n Starting NX ... \n"
  316.  
  317. # Check for and run Spaceball or Magellan (a.k.a. SpaceMouse).
  318. # Check if any one of the spaceball/magellan device files is there. AND
  319. # the magellan script is present, if so, then run it.
  320. [ -c /dev/spaceball -o -c /dev/smouse -o -c /dev/magellan ] && {
  321. # Make sure the script is there, then run it.
  322. [ -x ${UGII_BASE_DIR}/ugii/magellan.ksh ] && {
  323. ${UGII_BASE_DIR}/ugii/magellan.ksh 2>$NU
  324. }
  325. }
  326.  
  327. echo "\n Starting UGRAF ... \n"
  328.  
  329. # Now START the ugraf image with the command line arguments.
  330. ${UGII_BASE_DIR}/ugii/$UGRAF_IMAGE "${@}"
  331.  
  332. # After ugraf, check for a "-d" debug switch. If so, pause after execution.
  333. echo $CMD_LINE_ARGS | tr " " "\012" | grep ' \-d' 1>$NU 2>$NU && {
  334. echo "\n\t\tPress <Return> to continue \c" ; read CR ; exit 1
  335. }
  336.  
  337. exit 0 # All done.
  338.  
  339. # END ************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement