_script-util.sh revision d3ce44d37110c284dad15122841fd97ee41d9ac5
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# CDDL HEADER START
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# The contents of this file are subject to the terms of the
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# Common Development and Distribution License, Version 1.0 only
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# (the "License"). You may not use this file except in compliance
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# with the License.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# You can obtain a copy of the license at
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# trunk/opends/resource/legal-notices/OpenDS.LICENSE
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# See the License for the specific language governing permissions
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# and limitations under the License.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# When distributing Covered Code, include this CDDL HEADER in each
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# file and include the License file at
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# add the following below this CDDL HEADER, with the fields enclosed
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# by brackets "[]" replaced with your own identifying information:
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# Portions Copyright [yyyy] [name of copyright owner]
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# CDDL HEADER END
8bf067f46db522a89becdd33572a68963ae5dce0jvergara# Copyright 2008-2010 Sun Microsystems, Inc.
d3ce44d37110c284dad15122841fd97ee41d9ac5ludo# Portions Copyright 2010-2011 ForgeRock AS
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# Display an error message
2ffcba79653c7f754d15fe9be1bf21378c601f81ludovicp echo "Please set OPENDS_JAVA_HOME to the root of a Java 6 update 10 (or higher) installation"
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara echo "or edit the java.properties file and then run the dsjavaproperties script to"
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that tests the JAVA_HOME env variable.
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that tests the JAVA_BIN env variable.
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that tests the java executable in the PATH env variable.
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that tests the OPENDS_JAVA_HOME env variable.
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that tests the OPENDS_JAVA_BIN env variable.
ebf178d895c6d928d23c9f22bc0520c9cb991086jvergara# function that sets the java home
a3eae3a580853d8f1e40a236900143bef7b30a19abobrov# Determine whether the detected Java environment is acceptable for use.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara if test ${RESULT_CODE} -eq 13
8fd3bbe5654a26bb33b1a3bbfd158f272ee0d18cludovicp # This is a particular error code that means that the Java version is 6
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara # but not supported. Let InstallDS to display the localized error message
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara elif test ${RESULT_CODE} -ne 0
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "ERROR: The detected Java version could not be used. The detected"
2ffcba79653c7f754d15fe9be1bf21378c601f81ludovicp echo "You must specify the path to a valid Java 6.0 update 10 or higher version."
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "1. Delete the file ${INSTANCE_ROOT}/lib/set-java-home" if it exists.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "2. Set the environment variable OPENDS_JAVA_HOME to the root of a valid "
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "If you want to have specific Java settings for each command line you must"
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "3. Edit the properties file specifying the Java binary and the Java arguments"
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "for each command line. The Java properties file is located in:"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "4. Run the command-line ${INSTANCE_ROOT}/bin/dsjavaproperties"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara if test ${RESULT_CODE} -eq 13
8fd3bbe5654a26bb33b1a3bbfd158f272ee0d18cludovicp # This is a particular error code that means that the Java version is 6
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara # but not supported. Let InstallDS to display the localized error message
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t
da8294d71b7f77aa6cf6620af53b0ea864c2db8bjvergara elif test ${RESULT_CODE} -ne 0
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "ERROR: The detected Java version could not be used with the set of Java"
2ffcba79653c7f754d15fe9be1bf21378c601f81ludovicp echo "You must specify the path to a valid Java 6.0 update 10 or higher version."
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "1. Delete the file ${INSTANCE_ROOT}/lib/set-java-home" if it exists.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "2. Set the environment variable OPENDS_JAVA_HOME to the root of a valid "
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "If you want to have specific Java settings for each command line you must"
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "3. Edit the properties file specifying the Java binary and the Java arguments"
de386868bf369f19a6d4ffeb2bbdd4aa2146d769jvergara echo "for each command line. The Java properties file is located in:"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara echo "4. Run the command-line ${INSTANCE_ROOT}/bin/dsjavaproperties"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# system environment variables for security and compatibility reasons.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara export PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=${SCRIPT_NAME}
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# Configure the appropriate CLASSPATH.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara # Capture the current working directory so that we can change to it later.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara # Then capture the location of this script and the Directory Server instance
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara # root so that we can use them to create appropriate paths.
d319724fed3be916a9f68676aac6eb203d44b551chebrard cd "${WORKING_DIR}"
b39429129734a9adb7ac0d662e2e378534d58415jvergara if [ -f "${INSTALL_ROOT}/configure" ]
6733dfd94dda39b3bce6e9fe9713d4d2379cbb85chebrard echo "${INSTALL_ROOT}/configure has already been run. Exiting."
2f9e866dc4cbcbfdc541e27291fee3f2435485ddchebrard echo "No instance found. Run ${INSTALL_ROOT}/configure to create it."
b39429129734a9adb7ac0d662e2e378534d58415jvergara if [ -f "${INSTALL_ROOT}/instance.loc" ]
d319724fed3be916a9f68676aac6eb203d44b551chebrard if [ -d "${INSTANCE_ROOT}" ]
d8ce179034d9423197a842266e78c67275c6b601ctissot cd "${INSTANCE_ROOT}"
d8ce179034d9423197a842266e78c67275c6b601ctissot cd "${CURRENT_DIR}"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraif test "${SCRIPT_UTIL_CMD}" = "set-full-environment-and-test-java"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraelif test "${SCRIPT_UTIL_CMD}" = "set-full-environment"
b39429129734a9adb7ac0d662e2e378534d58415jvergara elif test "${SCRIPT_UTIL_CMD}" = "set-java-home-and-args"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraelif test "${SCRIPT_UTIL_CMD}" = "set-environment-vars"
6733dfd94dda39b3bce6e9fe9713d4d2379cbb85chebrardif [ "${SCRIPT_NAME}" != "configure" ] && [ "${SCRIPT_NAME}" != "unconfigure" ]
2f9e866dc4cbcbfdc541e27291fee3f2435485ddchebrard # Perform check unless it is specified not to do it
2f9e866dc4cbcbfdc541e27291fee3f2435485ddchebrard # No check for --version or --help option
d319724fed3be916a9f68676aac6eb203d44b551chebrard # Check instance
d319724fed3be916a9f68676aac6eb203d44b551chebrard # Launch the CheckInstance process.
b39429129734a9adb7ac0d662e2e378534d58415jvergara "${OPENDS_JAVA_BIN}" ${SCRIPT_NAME_ARG} "-DINSTALL_ROOT=${INSTALL_ROOT}" "-DINSTANCE_ROOT=${INSTANCE_ROOT}" org.opends.server.tools.configurator.CheckInstance --currentUser ${CURRENT_USER} ${OPT_CHECK_VERSION}
d319724fed3be916a9f68676aac6eb203d44b551chebrard # return part