home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / JBuilder8.iso / Solaris / resource / jre / bin / ControlPanel < prev    next >
Encoding:
Text File  |  2002-09-06  |  5.2 KB  |  196 lines

  1. #!/bin/sh
  2.  
  3. # Shell Script to run the Java(tm) Plug-in control panel.
  4.  
  5. # Parse the command-line options
  6. # -r means make associate with the container (i.e browser)
  7. # -u means remove the association with the container
  8. # -c provides the location of the container install
  9. # -j provides the location of the jre install
  10. # if neither -r or -u are specified, run the ControlPanel UI
  11.  
  12. USAGE='usage: ControlPanel [ (-u scheme | -r scheme) -c cpath -j jrepath ]'
  13. JLERROR='ControlPanel: Error: Invalid JRE location: '
  14. CLERROR='ControlPanel: Error: Invalid container location: '
  15. IPERROR='ControlPanel: Error: Insufficient permission'
  16. ISERROR='ControlPanel: Error: Invalid scheme: '
  17.  
  18. check_container_dir() {
  19.  
  20.    if [ ! -d ${1} ]; then
  21.       echo "${CLERROR}${2}"
  22.       exit 1
  23.    fi
  24.    if [ ! -w ${1} ]; then
  25.       echo "${IPERROR}"
  26.       exit 1
  27.    fi
  28. }
  29.  
  30. link_logic() {
  31.    if [ ${mode} = "reg" ]; then
  32.       ln -s ${1} ${2}
  33.    else
  34.       rm -f ${2}
  35.    fi
  36. }
  37.  
  38. while getopts ":r:u:c:j:" opt; do
  39.    case $opt in
  40.       r ) mode="reg";no_ui="true";scheme=${OPTARG}
  41.           ;;
  42.       u ) mode="unreg";no_ui="true";scheme=${OPTARG}
  43.           ;;
  44.       c ) container_home=${OPTARG}
  45.           ;;
  46.       j ) java_home=${OPTARG}
  47.           ;;
  48.       : ) echo ${USAGE}
  49.           exit 1
  50.           ;;
  51.      \? ) echo ${USAGE}
  52.           exit 1
  53.           ;;
  54.    esac
  55. done
  56.  
  57. if [ ${mode} ]; then
  58.    if [ -z "${java_home}" -o -z "${container_home}" ]; then
  59.       echo ${USAGE}
  60.       exit 1
  61.    fi
  62. else
  63.    if [ -n "${java_home}" -o -n "${container_home}" ]; then
  64.       echo ${USAGE}
  65.       exit 1
  66.    fi
  67. fi   
  68.  
  69. PRG=$0
  70. progname=`basename $0`
  71. os=`uname -s`
  72.  
  73. PLUGIN_VERSION=1.4.1 
  74. PLUGIN_NODOTVERSION=141 
  75.  
  76. if [ "${os}" = "Linux" ]; then
  77.     case "`uname -m`" in
  78.     i[3-9]86  | ia32 | ia64)
  79.         proc=i386
  80.         ;;
  81.     sparc*)
  82.         proc=sparc
  83.         ;;
  84.     *)
  85.         proc="`uname -m`"
  86.         ;;
  87.     esac
  88.     linktest="-L"
  89. else
  90.     proc=`uname -p`
  91.     linktest="-h"
  92. fi
  93.  
  94. # Resolve symlinks. See 4152645.
  95. while [ "${linktest}" "${PRG}" ]; do
  96.     ls=`/usr/bin/ls -ld "${PRG}"`
  97.     link=`/usr/bin/expr "${ls}" : '^.*-> \(.*\)$'`
  98.     if /usr/bin/expr "${link}" : '^/' > /dev/null; then
  99.     PRG="${link}"
  100.     else
  101.     PRG="`dirname ${PRG}`/${link}"
  102.     fi
  103. done
  104.  
  105. APPHOME=`dirname "${PRG}"`/..
  106. JREHOME=${APPHOME}/jre
  107. export APPHOME JREHOME
  108.  
  109. # Where is JRE?
  110. unset jre
  111. if [ -f "${JREHOME}/lib/${proc}/libjava.so" ]; then
  112.     jre="${JREHOME}"
  113. fi
  114. if [ -f "${APPHOME}/lib/${proc}/libjava.so" ]; then
  115.     jre="${APPHOME}"
  116. fi
  117. if [ "x${jre}" = "x" ]; then
  118.     echo "Error: can't find libjava.so."
  119.     exit 1
  120. fi
  121.  
  122. if [ "${os}" = "Linux" ]; then
  123.     P=`pwd`
  124.     cd ${jre}
  125.     jre=`pwd`
  126.     cd ${P}
  127. fi
  128.  
  129.  
  130. if [ -n "${no_ui}" ]; then
  131.  
  132. # Do the "right" thing based on the provided scheme.
  133.    plugin_stem=${java_home}/plugin/${proc}
  134.    if [ ! -d ${plugin_stem} ]; then
  135.       echo "${JLERROR}${java_home}"
  136.       exit 1
  137.    fi
  138.  
  139.    case ${scheme} in
  140.         ns4 | ns4E )
  141.               plugin_location="${plugin_stem}/ns4"
  142.               if [ ${mode} = "reg" ]; then
  143.                  echo "${plugin_location}"
  144.               fi
  145.               ;;
  146.        ns4L ) 
  147.               plugin_location="${plugin_stem}/ns4"
  148.               filename=`ls ${plugin_location}`
  149.               container_target="${container_home}/plugins"
  150.               check_container_dir ${container_target} ${container_home}
  151.               link_logic ${plugin_location}/${filename} ${container_target}/${filename}
  152.               ;;
  153.       ns600 | ns600L )
  154.               plugin_location="${plugin_stem}/ns600"
  155.               filename=`ls ${plugin_location}`
  156.               container_target="${container_home}/plugins"
  157.               check_container_dir ${container_target} ${container_home}
  158.               link_logic ${plugin_location}/${filename} ${container_target}/${filename}
  159.               ;;
  160.       ns610R )
  161.               plugin_location="${plugin_stem}/ns610"
  162.               filename=`ls ${plugin_location}`
  163.               LD_LIBRARY_PATH=${container_home}
  164.               MOZILLA_FIVE_HOME=${container_home}
  165.               export LD_LIBRARY_PATH MOZILLA_FIVE_HOME
  166.               container_command=${container_home}/regxpcom
  167.               if [ ! -x ${container_command} ]; then
  168.                  echo "${CLERROR}${container_home}"
  169.                  exit 1
  170.               fi
  171.               if [ ! -w ${container_home}/component.reg ]; then
  172.                  echo "${IPERROR}"
  173.                  exit 1
  174.               fi
  175.               if [ ${mode} = "reg" ]; then
  176.                  ${container_command} ${plugin_location}/${filename}
  177.               else
  178.                  ${container_command} -u ${plugin_location}/${filename}
  179.               fi
  180.               ;;
  181.      ns610 | ns610L )
  182.               plugin_location="${plugin_stem}/ns610"
  183.               filename=`ls ${plugin_location}`
  184.               container_target="${container_home}/plugins"
  185.               check_container_dir ${container_target} ${container_home}
  186.               link_logic ${plugin_location}/${filename} ${container_target}/${filename}
  187.               ;;
  188.           * ) 
  189.               echo ${ISERROR}${scheme}
  190.               exit 1
  191.    esac
  192. else
  193.    ${APPHOME}/bin/java -Djavaplugin.user.profile=${USER_JPI_PROFILE} -Djavaplugin.version=${PLUGIN_VERSION} -Djavaplugin.nodotversion=${PLUGIN_NODOTVERSION} -classpath ${jre}/lib/javaplugin.jar:${jre}/lib/javaplugin_l10n.jar sun.plugin.panel.ControlPanel
  194. fi
  195.  
  196.