| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #!/bin/bash
- #
- # Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- # ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- #
- # Shell Script to run the Java Plug-in control panel.
- #
- # Parse the command-line options
- # -r means make associate with the container (i.e browser)
- # -u means remove the association with the container
- # -c provides the location of the container install
- # -j provides the location of the jre install
- # if neither -r or -u are specified, run the ControlPanel UI
- USAGE='usage: ControlPanel [ (-u scheme | -r scheme) -c cpath -j jrepath ]'
- JLERROR='ControlPanel: Error: Invalid JRE location: '
- CLERROR='ControlPanel: Error: Invalid container location: '
- IPERROR='ControlPanel: Error: Insufficient permission'
- ISERROR='ControlPanel: Error: Invalid scheme: '
- XLERROR='ControlPanel: Error: Invalid link or copy: '
- check_container_dir() {
- if [ ! -d ${1} ]; then
- echo "${CLERROR}${2}"
- exit 1
- fi
- if [ ! -w ${1} ]; then
- echo "${IPERROR}"
- exit 1
- fi
- }
- link_logic() {
- if [ ${mode} = "reg" ]; then
- ln -s ${1} ${2}
- else
- rm -f ${2}
- fi
- }
- #
- # Get the absolute path to a symbolic link's reference.
- #
- # Parameters:
- # $* : path - the path to the file (link) to dereference (can have spaces in
- # the path).
- #
- # Output:
- # This function writes the path to the link reference to stdout.
- #
- #
- dereference() {
- path="$*"
- result=
- #
- # Make sure the path is absolute
- #
- parent="`cd \`dirname \"${path}\"\`; pwd -P`"
- child="`basename \"${path}\"`"
- #
- # if parent == child, then path == /, and is already absolute
- #
- if [ "${parent}" != "${child}" ]; then
- path="${parent}/${child}"
- fi
- if [ -h "${path}" ]; then
- path=`ls -l "${path}" | sed -e "s#^.*${path} -> ##"`
- # make sure the path is still absolute (starts with '/')
- if expr "${path}" : '[^/]' > /dev/null; then
- path="${parent}/${path}"
- fi
- fi
- echo ${path}
- }
- #
- # Check for all the parts required to launch the control panel relative to the
- # given path.
- #
- #
- # Parameters:
- # $* : path - the path to examine, presumably the resolved path to this
- # script (can have spaces in the path).
- #
- # Output:
- # If successful, this function outputs the absolute path to a directory
- # containing the Java binary, and ../lib/deploy.jar; otherwise it outputs
- # an empty string. (Output is to stdout.)
- #
- # Note: the assumption is that this function returns either:
- #
- # <jdk-root>/jre/bin, or
- # <jre-root>/bin
- #
- # However, as long as the directory pointed by the path returned by this
- # function contains:
- #
- # ./java
- # ../lib/deploy.jar
- #
- # it should be possible to successfully launch the JCP from the given
- # information.
- #
- check_parts() {
- result="`cd \`dirname \"$*\"\`; pwd -P`"
- # if this is a JDK, we need the JRE subdir
- if [ -d "${result}/../jre/bin" ]; then
- result="`cd \`dirname \"$*\"\`/../jre/bin; pwd -P`"
- fi
- if [ ! -x "${result}/java" ] || [ ! -f "${result}/../lib/deploy.jar" ]; then
- result=
- fi
- echo ${result}
- }
- #
- # Launch the Java Control Panel.
- #
- # Parameters:
- # $* : path - the path of this script (can have spaces in the path).
- #
- launch_jcp() {
- path="$*"
- while [ -h ${path} ]; do
- path="`dereference ${path}`"
- done
- java_home="`check_parts ${path}`"
- if [ -n "${java_home}" ]; then
- # launch the JCP using paths relative to
- ${java_home}/java -Djavaplugin.user.profile=${USER_JPI_PROFILE} \
- -Xbootclasspath/a:${java_home}/../lib/deploy.jar \
- ${_JAVA_VM_OPTIONS} \
- com.sun.deploy.panel.ControlPanel
- else
- echo "${XLERROR}${java_home}"
- exit 1
- fi
- }
- #
- # Manage the process of registering/unregistering the Java Plug-in with a given
- # container (browser).
- #
- manage_container() {
- # Do the "right" thing based on the provided scheme.
- plugin_stem=${java_home}/plugin/${proc}
- if [ ! -d ${plugin_stem} ]; then
- echo "${JLERROR}${java_home}"
- exit 1
- fi
- case ${scheme} in
- ns4 | ns4E )
- plugin_location="${plugin_stem}/ns4"
- if [ ${mode} = "reg" ]; then
- echo "${plugin_location}"
- fi
- ;;
- ns4L )
- plugin_location="${plugin_stem}/ns4"
- filename=`ls ${plugin_location}`
- container_target="${container_home}/plugins"
- check_container_dir ${container_target} ${container_home}
- link_logic ${plugin_location}/${filename} ${container_target}/${filename}
- ;;
- ns610 | ns610L )
- plugin_location="${plugin_stem}/ns610"
- filename=`ls ${plugin_location}`
- container_target="${container_home}/plugins"
- check_container_dir ${container_target} ${container_home}
- link_logic ${plugin_location}/${filename} ${container_target}/${filename}
- ;;
- * )
- echo ${ISERROR}${scheme}
- exit 1
- esac
- }
- while getopts ":r:u:c:j:" opt; do
- case $opt in
- r ) mode="reg";scheme=${OPTARG}
- ;;
- u ) mode="unreg";scheme=${OPTARG}
- ;;
- c ) container_home=${OPTARG}
- ;;
- j ) java_home=${OPTARG}
- ;;
- : ) echo ${USAGE}
- exit 1
- ;;
- \? ) echo ${USAGE}
- exit 1
- ;;
- esac
- done
- os=`uname -s`
- if [ "${os}" = "Linux" ]; then
- case "`uname -m`" in
- i[3-9]86 | ia32 | ia64 | x86_64)
- proc=i386
- ;;
- sparc*)
- proc=sparc
- ;;
- arm*)
- proc=arm
- ;;
- ppc*)
- proc=ppc
- ;;
- *)
- proc="`uname -m`"
- ;;
- esac
- else
- proc=`uname -p`
- fi
- if [ -z "${scheme}" ] &&
- [ -z "${java_home}" ] && [ -z "${container_home}" ]
- then
- # just run the control panel
- launch_jcp $0
- elif [ -n "${scheme}" ] &&
- [ -n "${java_home}" ] && [ -n "${container_home}" ]
- then
- # try to register/unregister the plugin
- manage_container
- else
- # one or more missing args
- echo ${USAGE}
- exit 1
- fi
|