opendj-server-legacy/resource/upgrade
@@ -22,7 +22,7 @@ # CDDL HEADER END # # # Copyright 2013-2014 ForgeRock AS # Copyright 2013-2015 ForgeRock AS # This script may be used to perform a backup of a Directory Server backend. @@ -33,11 +33,25 @@ export SCRIPT_NAME SCRIPT_DIR=`dirname "${0}"` DIR_CLASSES="${SCRIPT_DIR}/classes" INSTALL_ROOT=${SCRIPT_DIR} export INSTALL_ROOT # Set environment variables SCRIPT_UTIL_CMD=set-environment-vars export SCRIPT_UTIL_CMD . "${INSTALL_ROOT}/lib/_script-util.sh" RETURN_CODE=$? if test ${RETURN_CODE} -ne 0 then exit ${RETURN_CODE} fi DIR_CLASSES="${INSTANCE_ROOT}/classes" # The upgrade is not compatible with patches. If the folder is not empty # we renamed it as "classes.disabled", and the upgrade process should be launched properly. if [ "`(ls -A ${DIR_CLASSES})`" ]; then mv -f ${DIR_CLASSES} "${SCRIPT_DIR}/classes.disabled" mv -f ${DIR_CLASSES} "${INSTANCE_ROOT}/classes.disabled" mkdir ${DIR_CLASSES} fi opendj-server-legacy/resource/upgrade.bat
@@ -22,7 +22,7 @@ rem CDDL HEADER END rem rem rem Copyright 2013-2014 ForgeRock AS rem Copyright 2013-2015 ForgeRock AS setlocal @@ -30,16 +30,29 @@ set SCRIPT_NAME=upgrade for %%i in (%~sf0) do set SCRIPT_DIR=%%~dPsi set DIR_CLASSES="%SCRIPT_DIR%classes" set INSTALL_ROOT=%DIR_HOME% set INSTANCE_DIR= if exist "%INSTALL_ROOT%\instance.loc" ( set /p INSTANCE_DIR=<%INSTALL_ROOT%\instance.loc ) else ( set INSTANCE_DIR=. ) set CUR_DIR=%CD% cd /d %INSTALL_ROOT% cd /d %INSTANCE_DIR% set INSTANCE_ROOT=%CD% cd /d %CUR_DIR% set DIR_CLASSES="%INSTANCE_ROOT%classes" rem The upgrade is not compatible with patches. If the folder is not empty rem we renamed it as "classes.disabled", and the upgrade process should be launched properly. IF EXIST "%DIR_CLASSES%" ( for /F %%i in ('dir /b %DIR_CLASSES%\*.*') do goto renamePatchesFolder for /F %%i in ('dir /b %DIR_CLASSES%\*.*') do goto renamePatchesFolder ) goto end :renamePatchesFolder move /-Y "%DIR_CLASSES%" "%SCRIPT_DIR%classes.disabled" > nul move /-Y "%DIR_CLASSES%" "%INSTANCE_ROOT%classes.disabled" > nul mkdir %DIR_CLASSES% :end opendj-server-legacy/src/main/java/org/opends/quicksetup/LicenseFile.java
@@ -46,6 +46,7 @@ */ public class LicenseFile { private static final String INSTALL_ROOT_SYSTEM_PROPERTY = "INSTALL_ROOT"; /** * The license file name in Legal directory. @@ -65,24 +66,26 @@ /** * Get the directory in which legal files are stored. */ private static String getInstanceLegalDirectory() { String instanceLegalDirName; String installDirName = System.getProperty("INSTALL_ROOT"); private static String getInstallDirectory() { String installDirName = System.getProperty(INSTALL_ROOT_SYSTEM_PROPERTY); if (installDirName == null) { installDirName = System.getenv("INSTALL_ROOT"); installDirName = System.getenv(INSTALL_ROOT_SYSTEM_PROPERTY); } if (installDirName == null) { installDirName = "."; } return installDirName; } String instanceDirname = Utils.getInstancePathFromInstallPath(installDirName); instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME; /** * Get the directory in which approved legal files are stored. */ private static String getInstanceLegalDirectory() { String instanceLegalDirName = Utils.getInstancePathFromInstallPath(getInstallDirectory()) + File.separator + LEGAL_FOLDER_NAME; File instanceLegalDir = new File(instanceLegalDirName); if (!instanceLegalDir.exists()) { @@ -106,8 +109,7 @@ */ private static String getName() { return getInstanceLegalDirectory() + File.separatorChar + LICENSE_FILE_NAME; return getInstallDirectory() + File.separator + LEGAL_FOLDER_NAME + File.separator + LICENSE_FILE_NAME; } /** @@ -141,7 +143,7 @@ */ public static String getText() { InputStream input = null; InputStream input; try { input = new FileInputStream(getFile()); @@ -154,27 +156,23 @@ // Reads the inputstream content. final StringBuilder sb = new StringBuilder(); if (input != null) try { try { final BufferedReader br = new BufferedReader(new InputStreamReader(input)); String read = br.readLine(); final BufferedReader br = new BufferedReader(new InputStreamReader(input)); String read = br.readLine(); while (read != null) { sb.append(read); sb.append(ServerConstants.EOL); read = br.readLine(); } } catch (IOException ioe) while (read != null) { // Should not happen return ""; sb.append(read); sb.append(ServerConstants.EOL); read = br.readLine(); } } catch (IOException ioe) { // Should not happen return ""; } StaticUtils.close(input); return sb.toString(); @@ -213,10 +211,17 @@ { if (getApproval() && installationPath != null) { String instanceDirname = Utils.getInstancePathFromInstallPath(installationPath); String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME; File instanceLegalDir = new File(instanceLegalDirName); try { new File(installationPath + File.separatorChar + LEGAL_FOLDER_NAME + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME).createNewFile(); if (!instanceLegalDir.exists()) { instanceLegalDir.mkdir(); } new File(instanceLegalDir, ACCEPTED_LICENSE_FILE_NAME).createNewFile(); } catch (IOException e) { @@ -233,10 +238,7 @@ */ public static boolean isAlreadyApproved() { final File f = new File(getInstanceLegalDirectory() + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME); return f.exists(); return new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).exists(); } } opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
@@ -53,9 +53,6 @@ */ private static final String LEGAL_FOLDER_NAME = "legal-notices"; /** List of possible folder of the accepted license file. */ private static final String[] ACCEPTED_LICENSE_FOLDER_NAMES = new String[] { LEGAL_FOLDER_NAME, "Legal" }; /** * The accepted license file name. */ @@ -65,7 +62,7 @@ * Try to find the local instance path from system property or environment. If * both are null, return the provided fallback value. */ private static String getInstanceRootPathFromSystem(final String fallBackValue) private static String getInstallRootPathFromSystem(final String fallBackValue) { final String[] possibleValues = new String[] { System.getProperty(INSTALL_ROOT_SYSTEM_PROPERTY), System.getenv(INSTALL_ROOT_SYSTEM_PROPERTY) }; @@ -82,7 +79,7 @@ /** Get the directory in which legal files are stored. */ private static String getLegalDirectory() { return getInstanceRootPathFromSystem("") + File.separatorChar + LEGAL_FOLDER_NAME; return getInstallRootPathFromSystem(".") + File.separator + LEGAL_FOLDER_NAME; } /** @@ -90,7 +87,7 @@ */ private static String getInstanceLegalDirectory() { final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstanceRootPathFromSystem(".")); final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstallRootPathFromSystem(".")); final String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME; final File instanceLegalDir = new File(instanceLegalDirName); if (!instanceLegalDir.exists()) @@ -115,7 +112,7 @@ */ private static String getName() { return getLegalDirectory() + File.separatorChar + LICENSE_FILE_NAME; return getLegalDirectory() + File.separator + LICENSE_FILE_NAME; } /** @@ -212,11 +209,10 @@ { try { new File(getInstanceLegalDirectory() + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME).createNewFile(); new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).createNewFile(); } catch (IOException e) { { // do nothing } } } @@ -229,16 +225,7 @@ */ public static boolean isAlreadyApproved() { for (final String folderName : ACCEPTED_LICENSE_FOLDER_NAMES) { final File f = new File(getInstanceRootPathFromSystem(".") + File.separatorChar + folderName + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME); if (f.exists()) { return true; } } return false; return new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).exists(); } }