_script-util.bat revision 6238
0N/A@echo off
0N/Arem CDDL HEADER START
0N/Arem
0N/Arem The contents of this file are subject to the terms of the
0N/Arem Common Development and Distribution License, Version 1.0 only
0N/Arem (the "License"). You may not use this file except in compliance
0N/Arem with the License.
0N/Arem
0N/Arem You can obtain a copy of the license at
0N/Arem trunk/opends/resource/legal-notices/OpenDS.LICENSE
0N/Arem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0N/Arem See the License for the specific language governing permissions
0N/Arem and limitations under the License.
0N/Arem
0N/Arem When distributing Covered Code, include this CDDL HEADER in each
0N/Arem file and include the License file at
0N/Arem trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
0N/Arem add the following below this CDDL HEADER, with the fields enclosed
0N/Arem by brackets "[]" replaced with your own identifying information:
0N/Arem Portions Copyright [yyyy] [name of copyright owner]
0N/Arem
0N/Arem CDDL HEADER END
0N/Arem
0N/Arem
0N/Arem Copyright 2008-2010 Sun Microsystems, Inc.
0N/Arem Portions Copyright 2011-2013 ForgeRock AS
0N/A
0N/Aset SET_JAVA_HOME_AND_ARGS_DONE=false
0N/Aset SET_ENVIRONMENT_VARS_DONE=false
0N/Aset SET_CLASSPATH_DONE=false
0N/A
0N/Aif "%INSTALL_ROOT%" == "" goto setInstanceRoot
0N/A
0N/A:scriptBegin
0N/Aif "%SCRIPT_UTIL_CMD%" == "set-full-environment-and-test-java" goto setFullEnvironmentAndTestJava
0N/Aif "%SCRIPT_UTIL_CMD%" == "set-full-environment" goto setFullEnvironment
0N/Aif "%SCRIPT_UTIL_CMD%" == "set-java-home-and-args" goto setJavaHomeAndArgs
0N/Aif "%SCRIPT_UTIL_CMD%" == "set_environment_vars" goto setEnvironmentVars
0N/Aif "%SCRIPT_UTIL_CMD%" == "test-java" goto testJava
0N/Aif "%SCRIPT_UTIL_CMD%" == "set-classpath" goto setClassPath
0N/Agoto end
0N/A
0N/A:setInstanceRoot
0N/Asetlocal
0N/Afor %%i in (%~sf0) do set DIR_HOME=%%~dPsi..
0N/Aset INSTALL_ROOT=%DIR_HOME%
0N/Aset INSTANCE_DIR=
0N/Afor /f "delims=" %%a in (%INSTALL_ROOT%\instance.loc) do (
0N/A set INSTANCE_DIR=%%a
0N/A)
0N/Aset CUR_DIR=%CD%
0N/Acd /d %INSTALL_ROOT%
0N/Acd /d %INSTANCE_DIR%
0N/Aset INSTANCE_ROOT=%CD%
0N/Acd /d %CUR_DIR%
0N/Agoto scriptBegin
0N/A
0N/A
0N/A:setClassPath
0N/Aif "%SET_CLASSPATH_DONE%" == "true" goto end
0N/AFOR %%x in ("%INSTALL_ROOT%\lib\*.jar") DO call "%INSTALL_ROOT%\lib\setcp.bat" %%x
0N/Aif "%INSTALL_ROOT%" == "%INSTANCE_ROOT%"goto setClassPathDone
0N/AFOR %%x in ("%INSTANCE_ROOT%\lib\*.jar") DO call "%INSTANCE_ROOT%\lib\setcp.bat" %%x
0N/AFOR %%x in ("%INSTALL_ROOT%\resources\*.jar") DO call "%INSTALL_ROOT%\lib\setcp.bat" %%x
0N/Aset CLASSPATH=%INSTANCE_ROOT%\classes;%CLASSPATH%
0N/A:setClassPathDone
0N/Aset SET_CLASSPATH_DONE=true
0N/Agoto scriptBegin
0N/A
0N/A:setFullEnvironment
0N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "false" goto setJavaHomeAndArgs
0N/Aif "%SET_CLASSPATH_DONE%" == "false" goto setClassPath
0N/Aif "%SET_ENVIRONMENT_VARS_DONE%" == "false" goto setEnvironmentVars
0N/Agoto end
0N/A
0N/A:setFullEnvironmentAndTestJava
0N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "false" goto setJavaHomeAndArgs
0N/Aif "%SET_CLASSPATH_DONE%" == "false" goto setClassPath
0N/Aif "%SET_ENVIRONMENT_VARS_DONE%" == "false" goto setEnvironmentVars
0N/Agoto testJava
0N/A
0N/A
0N/A:setJavaHomeAndArgs
0N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "true" goto end
0N/Aif not exist "%INSTANCE_ROOT%\lib\set-java-home.bat" goto checkEnvJavaHome
0N/Acall "%INSTANCE_ROOT%\lib\set-java-home.bat"
0N/Aif "%OPENDJ_JAVA_BIN%" == "" goto checkEnvJavaHome
0N/A:endJavaHomeAndArgs
0N/Aset SET_JAVA_HOME_AND_ARGS_DONE=true
0N/Agoto scriptBegin
0N/A
0N/A:checkEnvJavaHome
0N/Aif "%OPENDJ_JAVA_BIN%" == "" goto checkEnvLegacyJavaHome
0N/Aif not exist "%OPENDJ_JAVA_BIN%" goto checkEnvLegacyJavaHome
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:checkEnvLegacyJavaHome
0N/Aif "%OPENDS_JAVA_BIN%" == "" goto checkOpenDJJavaHome
0N/Aif not exist "%OPENDS_JAVA_BIN%" goto checkOpenDJJavaHome
0N/Aset OPENDJ_JAVA_BIN=%OPENDS_JAVA_BIN%
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A
0N/A:checkOpenDJJavaHome
0N/Aif "%OPENDJ_JAVA_HOME%" == "" goto checkLegacyOpenDSJavaHome
0N/Aif not exist "%OPENDJ_JAVA_HOME%\bin\java.exe" goto checkLegacyOpenDSJavaHome
0N/Aset OPENDJ_JAVA_BIN=%OPENDJ_JAVA_HOME%\bin\java.exe
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:checkLegacyOpenDSJavaHome
0N/Aif "%OPENDS_JAVA_HOME%" == "" goto checkJavaPath
0N/Aif not exist "%OPENDS_JAVA_HOME%\bin\java.exe" goto checkJavaPath
0N/Aset OPENDJ_JAVA_BIN=%OPENDS_JAVA_HOME%\bin\java.exe
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:checkJavaPath
0N/Ajava.exe -version > NUL 2>&1
0N/Aif not %errorlevel% == 0 goto checkJavaBin
0N/Aset OPENDJ_JAVA_BIN=java.exe
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:checkJavaBin
0N/Aif "%JAVA_BIN%" == "" goto checkJavaHome
0N/Aif not exist "%JAVA_BIN%" goto checkJavaHome
0N/Aset OPENDJ_JAVA_BIN=%JAVA_BIN%
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:checkJavaHome
0N/Aif "%JAVA_HOME%" == "" goto noJavaFound
0N/Aif not exist "%JAVA_HOME%\bin\java.exe" goto noJavaFound
0N/Aset OPENDJ_JAVA_BIN=%JAVA_HOME%\bin\java.exe
0N/Agoto endJavaHomeAndArgs
0N/A
0N/A:noJavaFound
0N/Aecho ERROR: Could not find a valid Java binary to be used.
0N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
0N/Aecho The procedure to follow is:
0N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
0N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
0N/Aecho Java 6.0 installation.
0N/Aecho If you want to have specific Java settings for each command line you must
0N/Aecho follow the steps 3 and 4.
0N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
0N/Aecho for each command line. The Java properties file is located in:
0N/Aecho %INSTANCE_ROOT%\config\java.properties.
0N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
0N/Apause
0N/Aexit /B 1
0N/A
0N/A:setEnvironmentVars
0N/Aif %SET_ENVIRONMENT_VARS_DONE% == "true" goto end
0N/Aset PATH=%SystemRoot%;%PATH%
0N/Aset SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=%SCRIPT_NAME%
0N/Aset SET_ENVIRONMENT_VARS_DONE=true
0N/Agoto scriptBegin
0N/A
0N/A:testJava
0N/Aif "%OPENDJ_JAVA_ARGS%" == "" goto checkLegacyArgs
0N/A:continueTestJava
0N/A"%OPENDJ_JAVA_BIN%" %OPENDJ_JAVA_ARGS% org.opends.server.tools.InstallDS -t > NUL 2>&1
0N/Aset RESULT_CODE=%errorlevel%
0N/Aif %RESULT_CODE% == 13 goto notSupportedJavaHome
0N/Aif not %RESULT_CODE% == 0 goto noValidJavaHome
0N/Agoto end
0N/A
0N/A:checkLegacyArgs
0N/Aif "%OPENDS_JAVA_ARGS%" == "" goto continueTestJava
0N/Aset OPENDJ_JAVA_ARGS=%OPENDS_JAVA_ARGS%
0N/Agoto continueTestJava
0N/A
0N/A:noValidJavaHome
0N/Aif NOT "%OPENDJ_JAVA_ARGS%" == "" goto noValidHomeWithArgs
0N/Aecho ERROR: The detected Java version could not be used. The detected
0N/Aecho Java binary is:
0N/Aecho %OPENDJ_JAVA_BIN%
0N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
0N/Aecho The procedure to follow is:
0N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
0N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
0N/Aecho Java 6.0 installation.
0N/Aecho If you want to have specific Java settings for each command line you must
0N/Aecho follow the steps 3 and 4.
0N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
0N/Aecho for each command line. The Java properties file is located in:
0N/Aecho %INSTANCE_ROOT%\config\java.properties.
0N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
0N/Apause
0N/Aexit /B 1
0N/A
0N/A:notSupportedJavaHome
0N/Arem We get here when the java version is 6 (or up) but not supported. We run
0N/Arem InstallDS again to see a localized message.
0N/A"%OPENDJ_JAVA_BIN%" %OPENDJ_JAVA_ARGS% org.opends.server.tools.InstallDS -t
0N/Apause
0N/Aexit /B 1
0N/A
0N/A:noValidHomeWithArgs
0N/Aecho ERROR: The detected Java version could not be used with the set of Java
0N/Aecho arguments %OPENDJ_JAVA_ARGS%.
0N/Aecho The detected Java binary is:
0N/Aecho %OPENDJ_JAVA_BIN%
0N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
0N/Aecho The procedure to follow is:
0N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
0N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
0N/Aecho Java 6.0 installation.
0N/Aecho If you want to have specific Java settings for each command line you must
0N/Aecho follow the steps 3 and 4.
0N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
0N/Aecho for each command line. The Java properties file is located in:
0N/Aecho %INSTANCE_ROOT%\config\java.properties.
0N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
0N/Apause
0N/Aexit /B 1
0N/A
0N/A:end
0N/Aexit /B 0
0N/A