5 # Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
6 # ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
8 # Shell Script to run the Java(tm) Plug-in control panel.
10 # Parse the command-line options
11 # -r means make associate with the container (i.e browser)
12 # -u means remove the association with the container
13 # -c provides the location of the container install
14 # -j provides the location of the jre install
15 # if neither -r or -u are specified, run the ControlPanel UI
17 USAGE='usage: ControlPanel [ (-u scheme | -r scheme) -c cpath -j jrepath ]'
18 JLERROR='ControlPanel: Error: Invalid JRE location: '
19 CLERROR='ControlPanel: Error: Invalid container location: '
20 IPERROR='ControlPanel: Error: Insufficient permission'
21 ISERROR='ControlPanel: Error: Invalid scheme: '
22 XLERROR='ControlPanel: Error: Invalid link or copy: '
24 check_container_dir() {
26 if [ ! -d ${1} ]; then
30 if [ ! -w ${1} ]; then
37 if [ ${mode} = "reg" ]; then
45 # Get the absolute path to a symbolic link's reference.
48 # $* : path - the path to the file (link) to dereference (can have spaces in
52 # This function writes the path to the link reference to stdout.
54 # Note: This function is not capable of detecting that one or more directories
55 # in the path is also a link and unravelling that.
62 # Make sure the path is absolute
64 parent="`cd \`dirname \"${path}\"\`; pwd`"
65 child="`basename \"${path}\"`"
68 # if parent == child, then path == /, and is already absolute
70 if [ "${parent}" != "${child}" ]; then
71 path="${parent}/${child}"
74 if [ -h "${path}" ]; then
75 path=`ls -l "${path}" | sed -e "s#^.*${path} -> ##"`
77 # make sure the path is still absolute (starts with '/')
78 if expr "${path}" : '[^/]' > /dev/null; then
79 path="${parent}/${path}"
87 # Check for all the parts required to launch the control panel relative to the
92 # $* : path - the path to examine, presumably the resolved path to this
93 # script (can have spaces in the path).
96 # If successful, this function outputs the absolute path to a directory
97 # containing the Java binary, and ../lib/deploy.jar; otherwise it outputs
98 # an empty string. (Output is to stdout.)
100 # Note: the assumption is that this function returns either:
102 # <jdk-root>/jre/bin, or
105 # However, as long as the directory pointed by the path returned by this
111 # it should be possible to successfully launch the JCP from the given
115 result="`cd \`dirname \"$*\"\`; pwd`"
117 # if this is a JDK, we need the JRE subdir
118 if [ -d "${result}/../jre/bin" ]; then
119 result="`cd \`dirname \"$*\"\`/../jre/bin; pwd`"
122 if [ ! -x "${result}/java" ] || [ ! -f "${result}/../lib/deploy.jar" ]; then
130 # Launch the Java Control Panel.
133 # $* : path - the path of this script (can have spaces in the path).
137 while [ -h ${path} ]; do
138 path="`dereference ${path}`"
141 java_home="`check_parts ${path}`"
142 if [ -n "${java_home}" ]; then
143 # launch the JCP using paths relative to
144 ${java_home}/java -Djavaplugin.user.profile=${USER_JPI_PROFILE} \
145 -Xbootclasspath/a:${java_home}/../lib/deploy.jar \
146 ${_JAVA_VM_OPTIONS} \
147 com.sun.deploy.panel.ControlPanel
149 echo "${XLERROR}${java_home}"
155 # Manage the process of registering/unregistering the Java Plug-in with a given
156 # container (browser).
159 # Do the "right" thing based on the provided scheme.
160 plugin_stem=${java_home}/plugin/${proc}
161 if [ ! -d ${plugin_stem} ]; then
162 echo "${JLERROR}${java_home}"
168 plugin_location="${plugin_stem}/ns4"
169 if [ ${mode} = "reg" ]; then
170 echo "${plugin_location}"
174 plugin_location="${plugin_stem}/ns4"
175 filename=`ls ${plugin_location}`
176 container_target="${container_home}/plugins"
177 check_container_dir ${container_target} ${container_home}
178 link_logic ${plugin_location}/${filename} ${container_target}/${filename}
181 plugin_location="${plugin_stem}/ns610"
182 filename=`ls ${plugin_location}`
183 container_target="${container_home}/plugins"
184 check_container_dir ${container_target} ${container_home}
185 link_logic ${plugin_location}/${filename} ${container_target}/${filename}
188 echo ${ISERROR}${scheme}
193 while getopts ":r:u:c:j:" opt; do
195 r ) mode="reg";scheme=${OPTARG}
197 u ) mode="unreg";scheme=${OPTARG}
199 c ) container_home=${OPTARG}
201 j ) java_home=${OPTARG}
213 if [ "${os}" = "Linux" ]; then
215 i[3-9]86 | ia32 | ia64 | x86_64)
229 if [ -z "${scheme}" ] &&
230 [ -z "${java_home}" ] && [ -z "${container_home}" ]
232 # just run the control panel
234 elif [ -n "${scheme}" ] &&
235 [ -n "${java_home}" ] && [ -n "${container_home}" ]
237 # try to register/unregister the plugin
240 # one or more missing args