home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Adobe / bin / acroread.sh
Encoding:
Linux/UNIX/POSIX Shell Script  |  1995-11-01  |  5.0 KB  |  247 lines

  1. #!/bin/sh
  2. #
  3. # vi:set ts=40 sw=2:
  4. #
  5.  
  6. cmd=acroread
  7. prod="Acrobat Reader"
  8. ver=2.1
  9. install_dir=REPLACE_ME
  10.  
  11. #
  12. # Prepend a colon seperated environment variable
  13. # $1 string to be prepended
  14. # $2 environment variable
  15. #
  16. prepend()
  17. {
  18.   if [ -z "$2" -o "$2" = "$1" ] ; then
  19.     echo "$1"
  20.   else
  21.     first="`expr "$2" : '\([^:]*\):'`"
  22.     if [ "$first" = "$1" ] ; then
  23.       echo "$2"
  24.     else
  25.       echo "${1}:${2}"
  26.     fi
  27.   fi
  28. }
  29.  
  30.  
  31. #
  32. # Tests the version file in an installation directory.
  33. #
  34. test_install_dir()
  35. {
  36.   if [ "$1" -a -f "$1/AcroVersion" ] \
  37.   && [ "`cat $1/AcroVersion 2>/dev/null`" = "$ver" ] ; then
  38.     return 0
  39.   else
  40.     return 1
  41.   fi
  42. }
  43.  
  44.  
  45. #
  46. # Get the current working directory.
  47. # Try to avoid automounter directories by checking
  48. # if $HOME or $PWD is the same directory as pwd,
  49. # and removing the automount directory component.
  50. #
  51. cwd="`pwd 2> /dev/null`"
  52. if [ -z "$cwd" -o ! -d "$cwd" ] ; then
  53.   echo "ERROR: Cannot determine current directory."
  54.   exit 1
  55. fi
  56.  
  57. if [ "$HOME" -a -d "$HOME" ] && [ "`cd / ; cd "$HOME" ; pwd`" = "$cwd" ] ; then
  58.   cwd="$HOME"
  59. elif [ "$PWD" -a -d "$PWD" ] && [ "`cd / ; cd "$PWD" ; pwd`" = "$cwd" ] ; then
  60.   cwd="$PWD"
  61. fi
  62.  
  63. if [ "$cwd" != / -a "${AUTOMOUNT_DIR=/tmp_mnt}" ] ; then
  64.   tmp="`expr "$cwd" : "$AUTOMOUNT_DIR"'\(.*\)'`"
  65.   if [ "$tmp" -a -d "$tmp" ] ; then
  66.     if [ "`cd / ; cd "$tmp" ; pwd`" = "`pwd`" ] ; then
  67.       cwd="$tmp"
  68.     fi
  69.   fi
  70. fi
  71.  
  72. PWD="$cwd"
  73. export PWD
  74.  
  75.  
  76. #
  77. # Setup ACRO_ARG0 to this script
  78. #
  79. arg0="$0"
  80. if [ "$arg0" ] ; then
  81.   case "$arg0" in
  82.      /*) ;;
  83.     ./*) arg0="$cwd/`expr "$arg0" : '\./\(.*\)'`" ;;
  84.       *) arg0="$cwd/$arg0" ;;
  85.   esac
  86.  
  87.   ACRO_ARG0="$arg0"
  88.   export ACRO_ARG0
  89. fi
  90.  
  91.  
  92. #
  93. # Try to find the installation directory
  94. #
  95. if ( test_install_dir "$install_dir" ) ; then
  96.   ACRO_INSTALL_DIR="$install_dir"
  97.   export ACRO_INSTALL_DIR
  98. else
  99.   script="$arg0"
  100.   while [ "$script" ] ; do
  101.     install_dir="`dirname "$script"`"
  102.     if ( test_install_dir "$install_dir" ) ; then
  103.       ACRO_INSTALL_DIR="$install_dir"
  104.       export ACRO_INSTALL_DIR
  105.       break
  106.     fi
  107.  
  108.     install_dir="`dirname "$install_dir"`"
  109.     if ( test_install_dir "$install_dir" ) ; then
  110.       ACRO_INSTALL_DIR="$install_dir"
  111.       export ACRO_INSTALL_DIR
  112.       break
  113.     fi
  114.  
  115.     if [ -h "$script" ] ; then
  116.       new_script=`ls -l "$script" | sed 's/^.*-> *\(.*\) *$/\1/'`
  117.       if [ "$new_script" -a "`expr "$new_script" : '/.*'`" = 0 ] ; then
  118.         new_script="`dirname "$script"`/$new_script"
  119.       fi
  120.       script="$new_script"
  121.     else
  122.       break
  123.     fi
  124.   done
  125.  
  126.   if ( test_install_dir "$ACRO_INSTALL_DIR" ) ; then
  127.     :
  128.   elif ( test_install_dir "$ACRO_HOME" ) ; then
  129.     ACRO_INSTALL_DIR="$ACRO_HOME"
  130.     export ACRO_INSTALL_DIR
  131.   else
  132.     echo "ERROR: Cannot find installation directory."
  133.     exit 1
  134.   fi
  135. fi
  136.  
  137.  
  138. #
  139. # setup the configuration from uname
  140. #
  141. os_name=`uname -s`
  142. os_release=`uname -r`
  143.  
  144. case "$os_name" in
  145.   SunOS)
  146.     case "$os_release" in
  147.       4.1.3*|4.1.4*)
  148.         ACRO_CONFIG=sparcsun
  149.         export ACRO_CONFIG
  150.         ;;
  151.       5.*)
  152.         ACRO_CONFIG=sparcsolaris
  153.         export ACRO_CONFIG
  154.         ;;
  155.     esac
  156.     ;;
  157.   HP-UX)
  158.     ACRO_CONFIG=hppahpux
  159.     export ACRO_CONFIG
  160.     ;;
  161. esac
  162.  
  163. if [ -z "$ACRO_CONFIG" ] ; then
  164.   echo "The OS named $os_name version $os_release is currently not supported."
  165.   echo "Try running on a supported platform and connecting to your display."
  166.   echo "Supported platforms include the following:"
  167.   echo "  SPARC/SunOS version 4.1.3 or 4.1.4"
  168.   echo "  SPARC/Solaris version 2.x"
  169.   echo "  HP/HP-UX version 9.0.x and 10.x"
  170.   exit 1
  171. fi
  172.  
  173.  
  174. #
  175. # XXX No LANG
  176. #
  177.  
  178.  
  179. #
  180. # Setup XKEYSYMDB
  181. #
  182. if [ -z "$XKEYSYMDB" -o ! -f "$XKEYSYMDB" ] ; then
  183.   if [ -f "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/XKeysymDB" ] ; then
  184.     XKEYSYMDB="$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/XKeysymDB"
  185.     export XKEYSYMDB
  186.   elif [ -f "$ACRO_INSTALL_DIR/XKeysymDB" ] ; then
  187.     XKEYSYMDB="$ACRO_INSTALL_DIR/XKeysymDB"
  188.     export XKEYSYMDB
  189.   fi
  190. fi
  191.  
  192.  
  193. #
  194. # Prepend XFILESEARCHPATH
  195. #
  196. XFILESEARCHPATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/%T/%N%S" "$XFILESEARCHPATH"`"
  197. export XFILESEARCHPATH
  198.  
  199.  
  200. #
  201. # Setup configuration specific environment variables
  202. #
  203. case "$ACRO_CONFIG" in
  204.   sparcsun)
  205.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  206.     export LD_LIBRARY_PATH
  207.     XNLSPATH="$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib/nls"
  208.     export XNLSPATH
  209.     ;;
  210.   sparcsolaris)
  211.     LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$LD_LIBRARY_PATH"`"
  212.     export LD_LIBRARY_PATH
  213.     if [ -z "$LC_CTYPE" ] ; then
  214.       LC_CTYPE="iso_8859_1"
  215.       export LC_CTYPE
  216.     fi
  217.     ;;
  218.   hppahpux)
  219.     SHLIB_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib" "$SHLIB_PATH"`"
  220.     export SHLIB_PATH
  221.     ;;
  222. esac
  223.  
  224.  
  225. #
  226. # Set the command.  Process any debug flags and exec.
  227. #
  228. ACRO_EXEC_CMD="$ACRO_INSTALL_DIR/$ACRO_CONFIG/bin/$cmd"
  229.  
  230. if [ "$1" = "-DEBUG" ] ; then
  231.   if [ $# = 1 ] ; then
  232.     export ACRO_EXEC_CMD
  233.     exec "$SHELL"
  234.   else
  235.     shift
  236.     exec ${1+"$@"} "$ACRO_EXEC_CMD"
  237.   fi
  238. fi
  239.  
  240. if [ -f "$ACRO_EXEC_CMD" ] ; then
  241.   exec "$ACRO_EXEC_CMD" ${1+"$@"}
  242. else
  243.   echo "ERROR: $prod not installed for this configuration, \"$ACRO_CONFIG\"."
  244.   exit 1
  245. fi
  246.  
  247.