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