Fix 3534: Provide native Solaris packages (fix also 3533: upgrade fails starting server adding entry ds-cfg-key-id)
14 files added
35 files modified
| New file |
| | |
| | | <!-- |
| | | ! CDDL HEADER START |
| | | ! |
| | | ! The contents of this file are subject to the terms of the |
| | | ! Common Development and Distribution License, Version 1.0 only |
| | | ! (the "License"). You may not use this file except in compliance |
| | | ! with the License. |
| | | ! |
| | | ! You can obtain a copy of the license at |
| | | ! trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | ! or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | ! See the License for the specific language governing permissions |
| | | ! and limitations under the License. |
| | | ! |
| | | ! When distributing Covered Code, include this CDDL HEADER in each |
| | | ! file and include the License file at |
| | | ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | ! add the following below this CDDL HEADER, with the fields enclosed |
| | | ! by brackets "[]" replaced with your own identifying information: |
| | | ! Portions Copyright [yyyy] [name of copyright owner] |
| | | ! |
| | | ! CDDL HEADER END |
| | | ! |
| | | ! |
| | | ! Copyright 2006-2008 Sun Microsystems, Inc. |
| | | ! --> |
| | | |
| | | <project name="SVR4 Packaging" basedir="." default="package-svr4"> |
| | | <description> |
| | | This is a build script that extends the OpenDS build script by adding |
| | | SVR4 packaging functions. |
| | | </description> |
| | | |
| | | |
| | | <!-- By default will build OpenDS package --> |
| | | <property name="product" value="${SHORT_NAME}" /> |
| | | |
| | | |
| | | <!-- General properties --> |
| | | <property name="svr4.src.dir" location="src/svr4/${product}" /> |
| | | <property name="build.dir" location="build" /> |
| | | <property name="pkg.dir" location="${build.dir}/package" /> |
| | | <property name="svr4.dir" location="${build.dir}/package/svr4" /> |
| | | |
| | | <!-- Product specific properties: pkg.name / pkg.fullname / pkg.arch / pkg.desc / pkg.vendor / pkg.basedir --> |
| | | <property file="${svr4.src.dir}/pkg.properties" /> |
| | | |
| | | <!-- Default values for product specific properties --> |
| | | <property name="pkg.name" value="${product}" /> |
| | | <property name="pkg.fullname" value="${pkg.name}" /> |
| | | <property name="pkg.arch" value="all" /> |
| | | <property name="pkg.desc" value="${product}" /> |
| | | <property name="pkg.vendor" value="Sun Microsystems, Inc." /> |
| | | <property name="pkg.basedir" value="/opt" /> |
| | | |
| | | <!-- Some others general properties --> |
| | | <property name="svr4.build.dir" location="${build.dir}/package/svr4/build/${pkg.name}" /> |
| | | <property name="svr4.meta.dir" location="${svr4.build.dir}/meta" /> |
| | | <property name="svr4.layout.dir" location="${svr4.build.dir}/layout" /> |
| | | <property name="svr4.layout.pkg.dir" location="${svr4.build.dir}/layout/${pkg.name}" /> |
| | | |
| | | <!-- Must define layout/pkgversion target --> |
| | | <import file="${svr4.src.dir}/layout.xml" /> |
| | | |
| | | <!-- Check if OS is Solaris --> |
| | | <target name="checkos"> |
| | | <condition property="isSunOS"> |
| | | <os name="SunOS"/> |
| | | </condition> |
| | | </target> |
| | | |
| | | <target name="wrongos" unless="isSunOS"> |
| | | <echo message="OS is ${os.name}. SVR4 package can only be built on a SunOS machine" /> |
| | | </target> |
| | | |
| | | |
| | | <!-- Construct SVR4 package --> |
| | | <target name="svr4" depends="checkos,wrongos,cleansvr4,pkgversion,layout,metadata,pkgmk" if="isSunOS" |
| | | description="Construct ${pkg.name} package for product ${product}."> |
| | | <echo message="Package ${pkg.name} for product ${product} built in ${svr4.dir}" /> |
| | | </target> |
| | | |
| | | <!-- Cleanup target --> |
| | | <target name="cleansvr4" if="isSunOS" |
| | | description="Cleanup SVR4 files."> |
| | | <delete dir="${svr4.build.dir}" /> |
| | | <delete dir="${svr4.dir}/${pkg.name}" /> |
| | | </target> |
| | | |
| | | <!-- Construct metadata data --> |
| | | <target name="metadata" depends="pkginfo,prototype,copyright" if="isSunOS" |
| | | description="Construct metadata for ${pkg.name}."> |
| | | </target> |
| | | |
| | | <!-- Construct pkginfo file --> |
| | | <target name="pkginfo" if="isSunOS" depends="pkgversion" |
| | | description="Create pkginfo file based on ${svr4.src.dir}/info.properties" > |
| | | <echo message="Building pkginfo for ${pkg.name}" /> |
| | | <tstamp> |
| | | <format property="rev" pattern="yyyy.MM.dd"/> |
| | | </tstamp> |
| | | <mkdir dir="${svr4.meta.dir}"/> |
| | | <echo file="${svr4.meta.dir}/pkginfo"> |
| | | PKG=${pkg.name} |
| | | NAME=${pkg.fullname} |
| | | ARCH=${pkg.arch} |
| | | VERSION=${pkg.version},REV=${rev} |
| | | SUNW_PRODNAME=${pkg.desc} |
| | | SUNW_PRODVERS=${pkg.version} |
| | | SUNW_PKGVERS=1.0 |
| | | MAXINST=1000 |
| | | CATEGORY=application |
| | | DESC=${pkg.desc} |
| | | VENDOR=${pkg.vendor} |
| | | BASEDIR=${pkg.basedir} |
| | | CLASSES=none |
| | | HOTLINE=Please contact your local service provider |
| | | EMAIL= |
| | | </echo> |
| | | </target> |
| | | |
| | | <!-- Construct prototype file --> |
| | | <target name="prototype" depends="layout" if="isSunOS" |
| | | description="Create prototype file based on ${svr4.layout.dir}" > |
| | | <echo message="Building prototype for ${pkg.name} pkg" /> |
| | | <exec executable="pkgproto" dir="${svr4.layout.dir}" output="${svr4.meta.dir}/prototype"> |
| | | <arg value="."/> |
| | | </exec> |
| | | <exec executable="groups" dir="${svr4.layout.dir}" outputproperty="user.group" /> |
| | | <echo file="${svr4.meta.dir}/prototype" append="true">i pkginfo |
| | | i copyright</echo> |
| | | <replaceregexp file="${svr4.meta.dir}/prototype" |
| | | match="${user.name}" |
| | | replace="root" |
| | | byline="true"/> |
| | | <replaceregexp file="${svr4.meta.dir}/prototype" |
| | | match="${user.group}" |
| | | replace="sys" |
| | | byline="true"/> |
| | | |
| | | </target> |
| | | |
| | | <!-- Construct copyright file --> |
| | | <target name="copyright" if="isSunOS" |
| | | description="Create copyright file based on ${svr4.src.dir}/copyright" > |
| | | <echo message="Building copyright for ${pkg.name} pkg" /> |
| | | <copy file="${svr4.src.dir}/copyright" todir="${svr4.meta.dir}"/> |
| | | </target> |
| | | |
| | | <!-- Make package --> |
| | | <target name="pkgmk" if="isSunOS" |
| | | description="Build ${pkg.name} package" > |
| | | <echo message="Building ${pkg.name} pkg" /> |
| | | <echo message="Executing pkgmk -o -d ${svr4.dir} -r ${svr4.layout.dir} -f ${svr4.meta.dir}/prototype in ${svr4.layout.dir}" /> |
| | | <exec executable="pkgmk" dir="${svr4.layout.dir}"> |
| | | <arg value="-o"/> |
| | | <arg value="-d"/> |
| | | <arg value="${svr4.dir}"/> |
| | | <arg value="-r"/> |
| | | <arg value="${svr4.layout.dir}"/> |
| | | <arg value="-f"/> |
| | | <arg value="${svr4.meta.dir}/prototype"/> |
| | | </exec> |
| | | </target> |
| | | |
| | | </project> |
| | |
| | | </javac> |
| | | </target> |
| | | |
| | | <import file="build-svr4.xml"/> |
| | | |
| | | </project> |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | OLD_SCRIPT_NAME=${SCRIPT_NAME} |
| | |
| | | cd "`dirname "${0}"`" |
| | | cd .. |
| | | INSTALL_ROOT=`pwd` |
| | | cd "${WORKING_DIR}" |
| | | fi |
| | | |
| | | if test "${INSTANCE_ROOT}" = "" |
| | | then |
| | | for opt in `echo $*` |
| | | do |
| | | if [ $opt = "-V" ] || [ $opt = "--version" ] || |
| | | [ $opt = "-H" ] || [ $opt = "--help" ] |
| | | then |
| | | INSTANCE_ROOT="not_needed" |
| | | fi |
| | | done |
| | | fi |
| | | |
| | | if test "${INSTANCE_ROOT}" = "" |
| | | then |
| | | if [ -f ${INSTALL_ROOT}/configure ] |
| | | then |
| | | if [ -f /etc/opt/opends/instance.loc ] |
| | | then |
| | | if [ "${SCRIPT_NAME}" = "configure" ] |
| | | then |
| | | echo "${INSTALL_ROOT}/configure has already be run. Exiting." |
| | | exit 0 |
| | | fi |
| | | INSTANCE_ROOT=`cat /etc/opt/opends/instance.loc` |
| | | else |
| | | if [ "${SCRIPT_NAME}" != "configure" ] |
| | | then |
| | | echo "No instance found. Run ${INSTALL_ROOT}/configure to create it." |
| | | exit 1 |
| | | fi |
| | | fi |
| | | else |
| | | if [ -f ${INSTALL_ROOT}/instance.loc ] |
| | | then |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | fi |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT} |
| | | fi |
| | | fi |
| | | if [ -d "${INSTANCE_ROOT}" ] |
| | | then |
| | | cd ${INSTANCE_ROOT} |
| | | INSTANCE_ROOT=`pwd` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | cd "${WORKING_DIR}" |
| | | fi |
| | | |
| | | if test "${SCRIPT_UTIL_CMD}" = "set-full-environment-and-test-java" |
| | |
| | | then |
| | | test_java |
| | | fi |
| | | |
| | | current_user() |
| | | { |
| | | USER=`id` |
| | | CURRENT_IFS=${IFS} |
| | | IFS="()" |
| | | set -- ${USER} |
| | | echo $2 |
| | | IFS=${CURRENT_IFS} |
| | | } |
| | | |
| | | if [ "${SCRIPT_NAME}" != "configure" ] |
| | | then |
| | | NO_CHECK=0 |
| | | for opt in `echo $*` |
| | | do |
| | | # No check for --version or --help option |
| | | if [ $opt = "-V" ] || [ $opt = "--version" ] || |
| | | [ $opt = "-H" ] || [ $opt = "--help" ] || |
| | | [ $opt = "-F" ] || [ $opt = "--fullversion" ] |
| | | then |
| | | NO_CHECK=1 |
| | | fi |
| | | done |
| | | if [ ${NO_CHECK} -eq 0 ] |
| | | then |
| | | set_classpath |
| | | # Check instance |
| | | CURRENT_USER="`current_user`" |
| | | if [ "${CHECK_VERSION}" = "yes" ] |
| | | then |
| | | OPT_CHECK_VERSION="--checkVersion" |
| | | else |
| | | OPT_CHECK_VERSION="" |
| | | fi |
| | | # Launch the CheckInstance process. |
| | | "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} -DINSTALL_ROOT=${INSTALL_ROOT} -DINSTANCE_ROOT=${INSTANCE_ROOT} org.opends.quicksetup.configurator.CheckInstance --currentUser ${CURRENT_USER} ${OPT_CHECK_VERSION} |
| | | # return part |
| | | RETURN_CODE=$? |
| | | if [ ${RETURN_CODE} -ne 0 ] |
| | | then |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | fi |
| | | fi |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # Set environment variables |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | SCRIPT_DIR=`dirname "${0}"` |
| | | # Set environment variables |
| | | . "${INSTALL_ROOT}/lib/_script-util.sh" |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -ne 0 |
| | | then |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | |
| | | "${SCRIPT_DIR}/../lib/_server-script.sh" \ |
| | | --resourcePath "${INSTANCE_ROOT}/config/MakeLDIF" "${@}" |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # Specify the locations of important files that may be used when the server |
| | | # is starting. |
| | | CONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif |
| | | PID_FILE=${INSTANCE_ROOT}/logs/server.pid |
| | | LOG_FILE=${INSTANCE_ROOT}/logs/server.out |
| | | STARTING_FILE=${INSTANCE_ROOT}/logs/server.starting |
| | | |
| | | |
| | | # Specify the script name so that it may be provided in command-line usage. |
| | | SCRIPT_NAME="start-ds" |
| | |
| | | # Set environment variables |
| | | SCRIPT_UTIL_CMD=set-full-environment-and-test-java |
| | | export SCRIPT_UTIL_CMD |
| | | CHECK_VERSION=yes |
| | | export CHECK_VERSION |
| | | . "${INSTALL_ROOT}/lib/_script-util.sh" |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -ne 0 |
| | |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | |
| | | # Specify the locations of important files that may be used when the server |
| | | # is starting. |
| | | CONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif |
| | | PID_FILE=${INSTANCE_ROOT}/logs/server.pid |
| | | LOG_FILE=${INSTANCE_ROOT}/logs/server.out |
| | | STARTING_FILE=${INSTANCE_ROOT}/logs/server.starting |
| | | |
| | | |
| | | # See if the provided set of arguments were sufficient for us to be able to |
| | | # start the server or perform the requested operation. An exit code of 99 |
| | |
| | | INSTALL_ROOT=`pwd` |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # We keep this values to reset the environment before calling start-ds. |
| New file |
| | |
| | | #!/bin/sh |
| | | # |
| | | # CDDL HEADER START |
| | | # |
| | | # The contents of this file are subject to the terms of the |
| | | # Common Development and Distribution License, Version 1.0 only |
| | | # (the "License"). You may not use this file except in compliance |
| | | # with the License. |
| | | # |
| | | # You can obtain a copy of the license at |
| | | # trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | # or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | # See the License for the specific language governing permissions |
| | | # and limitations under the License. |
| | | # |
| | | # When distributing Covered Code, include this CDDL HEADER in each |
| | | # file and include the License file at |
| | | # trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | # add the following below this CDDL HEADER, with the fields enclosed |
| | | # by brackets "[]" replaced with your own identifying information: |
| | | # Portions Copyright [yyyy] [name of copyright owner] |
| | | # |
| | | # CDDL HEADER END |
| | | # |
| | | # |
| | | # Copyright 2006-2008 Sun Microsystems, Inc. |
| | | |
| | | |
| | | # Capture the current working directory so that we can change to it later. |
| | | # Then capture the location of this script and the Directory Server instance |
| | | # root so that we can use them to create appropriate paths. |
| | | WORKING_DIR=`pwd` |
| | | |
| | | cd "`dirname "${0}"`" |
| | | SCRIPT_DIR=`pwd` |
| | | |
| | | INSTALL_ROOT=${SCRIPT_DIR} |
| | | export INSTALL_ROOT |
| | | |
| | | SCRIPT_NAME=configure |
| | | export SCRIPT_NAME |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # Set environment variables |
| | | SCRIPT_UTIL_CMD=set-full-environment-and-test-java |
| | | export SCRIPT_UTIL_CMD |
| | | . "${INSTALL_ROOT}/lib/_script-util.sh" |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -ne 0 |
| | | then |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | |
| | | # Launch the configure process. |
| | | "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} -DINSTALL_ROOT=${INSTALL_ROOT} org.opends.quicksetup.configurator.Configurator "${@}" |
| | | |
| | | # return part |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -eq 50 |
| | | then |
| | | # Version info was on requested |
| | | exit 0 |
| | | else |
| | | exit ${RETURN_CODE} |
| | | fi |
| | |
| | | INSTALL_ROOT=${SCRIPT_DIR} |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | SCRIPT_NAME=setup |
| | | export SCRIPT_NAME |
| | | |
| | |
| | | INSTALL_ROOT=${SCRIPT_DIR} |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # Set environment variables |
| | |
| | | INSTALL_ROOT=${SCRIPT_DIR} |
| | | export INSTALL_ROOT |
| | | |
| | | if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null |
| | | then |
| | | INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | else |
| | | INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc` |
| | | export INSTANCE_ROOT |
| | | fi |
| | | |
| | | SCRIPT_NAME=upgrade |
| | | export SCRIPT_NAME |
| | | |
| New file |
| | |
| | | #!/bin/sh |
| | | # |
| | | # CDDL HEADER START |
| | | # |
| | | # The contents of this file are subject to the terms of the |
| | | # Common Development and Distribution License, Version 1.0 only |
| | | # (the "License"). You may not use this file except in compliance |
| | | # with the License. |
| | | # |
| | | # You can obtain a copy of the license at |
| | | # trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | # or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | # See the License for the specific language governing permissions |
| | | # and limitations under the License. |
| | | # |
| | | # When distributing Covered Code, include this CDDL HEADER in each |
| | | # file and include the License file at |
| | | # trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | # add the following below this CDDL HEADER, with the fields enclosed |
| | | # by brackets "[]" replaced with your own identifying information: |
| | | # Portions Copyright [yyyy] [name of copyright owner] |
| | | # |
| | | # CDDL HEADER END |
| | | # |
| | | # |
| | | # Copyright 2006-2008 Sun Microsystems, Inc. |
| | | |
| | | # Capture the current working directory so that we can change to it later. |
| | | # Then capture the location of this script and the Directory Server instance |
| | | # root so that we can use them to create appropriate paths. |
| | | WORKING_DIR=`pwd` |
| | | |
| | | cd "`dirname "${0}"`" |
| | | SCRIPT_DIR=`pwd` |
| | | |
| | | INSTALL_ROOT=${SCRIPT_DIR} |
| | | export INSTALL_ROOT |
| | | |
| | | SCRIPT_NAME=upgrade |
| | | export SCRIPT_NAME |
| | | |
| | | cd "${WORKING_DIR}" |
| | | |
| | | # Set java home |
| | | SCRIPT_UTIL_CMD=set-java-home-and-args |
| | | export SCRIPT_UTIL_CMD |
| | | . "${INSTALL_ROOT}/lib/_script-util.sh" |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -ne 0 |
| | | then |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | |
| | | # 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 |
| | | |
| | | # Configure the appropriate CLASSPATH to test. |
| | | #for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar |
| | | #do |
| | | # CLASSPATH=${CLASSPATH}:${JAR} |
| | | #done |
| | | CLASSPATH=${CLASSPATH}:${INSTANCE_ROOT}/classes |
| | | for JAR in ${INSTALL_ROOT}/lib/*.jar |
| | | do |
| | | CLASSPATH=${CLASSPATH}:${JAR} |
| | | done |
| | | export CLASSPATH |
| | | |
| | | # Test the java installation |
| | | SCRIPT_UTIL_CMD=test-java |
| | | export SCRIPT_UTIL_CMD |
| | | . "${INSTALL_ROOT}/lib/_script-util.sh" |
| | | RETURN_CODE=$? |
| | | if test ${RETURN_CODE} -ne 0 |
| | | then |
| | | exit ${RETURN_CODE} |
| | | fi |
| | | |
| | | if [ -r "${INSTANCE_ROOT}/tmp/upgrade" ] |
| | | then |
| | | rm -fr "${INSTANCE_ROOT}/tmp/upgrade" |
| | | fi |
| | | |
| | | # Launch the upgrade process. |
| | | "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} -DINSTALL_ROOT=${INSTALL_ROOT} org.opends.quicksetup.upgrader.UpgradeSvr4Launcher "${@}" |
| | |
| | | if (!f.isAbsolute()) |
| | | { |
| | | f = new File( |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(), |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(false), |
| | | schemaFile); |
| | | if (f == null || ! f.exists() || f.isDirectory()) |
| | | { |
| | | f = new File( |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(true), |
| | | schemaFile); |
| | | } |
| | | } |
| | | schemaFile = f.getAbsolutePath(); |
| | | return schemaFile; |
| | |
| | | backendSet = new HashSet<String>(); |
| | | CommonSchemaElements element = getSchemaElement(); |
| | | schemaFile = element.getSchemaFile(); |
| | | boolean userSchema = false ; |
| | | if (schemaFile == null) |
| | | { |
| | | schemaFile = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS; |
| | | userSchema = true; |
| | | } |
| | | File f = new File(schemaFile); |
| | | if (!f.isAbsolute()) |
| | | { |
| | | f = new File( |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(), |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(userSchema), |
| | | schemaFile); |
| | | } |
| | | schemaFile = f.getAbsolutePath(); |
| | |
| | | */ |
| | | private String getPropertiesFile() |
| | | { |
| | | String configDir = Utils.getPath( |
| | | getInfo().getServerDescriptor().getInstallPath().getAbsolutePath(), |
| | | Installation.CONFIG_PATH_RELATIVE); |
| | | String installPath = getInfo().getServerDescriptor(). |
| | | getInstallPath().getAbsolutePath(); |
| | | String propertiesFile = Utils.getPath( |
| | | configDir, Installation.DEFAULT_JAVA_PROPERTIES_FILE); |
| | | Utilities.getInstanceRootDirectory(installPath).getAbsolutePath(), |
| | | Installation.RELATIVE_JAVA_PROPERTIES_FILE); |
| | | return propertiesFile; |
| | | } |
| | | |
| | |
| | | schema = DirectoryServer.getSchema().duplicate(); |
| | | } |
| | | |
| | | private static String getSchemaDirectoryPath() |
| | | private static String getSchemaDirectoryPath(boolean userSchema) |
| | | { |
| | | File schemaDir = |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(); |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(userSchema); |
| | | if (schemaDir != null) { |
| | | return schemaDir.getAbsolutePath(); |
| | | } else { |
| | |
| | | */ |
| | | public void readSchema() throws ConfigException, InitializationException |
| | | { |
| | | String schemaDirPath= getSchemaDirectoryPath(); |
| | | File schemaDir = new File(schemaDirPath); |
| | | String[] attrsToKeep = { |
| | | ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC, |
| | | ConfigConstants.ATTR_OBJECTCLASSES_LC, |
| | |
| | | String[] fileNames = null; |
| | | try |
| | | { |
| | | String installPath = |
| | | new File(DirectoryServer.getServerRoot()).getCanonicalPath(); |
| | | String instancePath = |
| | | new File(DirectoryServer.getInstanceRoot()).getCanonicalPath(); |
| | | |
| | | // Load install directory schema |
| | | String schemaDirPath= getSchemaDirectoryPath(false); |
| | | File schemaDir = new File(schemaDirPath); |
| | | if (schemaDirPath == null || ! schemaDir.exists()) |
| | | { |
| | | Message message = ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaDirPath); |
| | |
| | | ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaDirPath); |
| | | throw new InitializationException(message); |
| | | } |
| | | File[] schemaInstallDirFiles = schemaDir.listFiles(); |
| | | File[] schemaInstanceDirFiles = null ; |
| | | int size = schemaInstallDirFiles.length; |
| | | |
| | | File[] schemaDirFiles = schemaDir.listFiles(); |
| | | ArrayList<String> fileList = new ArrayList<String>(schemaDirFiles.length); |
| | | for (File f : schemaDirFiles) |
| | | if (! installPath.equals(instancePath)) |
| | | { |
| | | schemaDirPath= getSchemaDirectoryPath(true); |
| | | schemaDir = new File(schemaDirPath); |
| | | if (schemaDirPath != null |
| | | && |
| | | schemaDir.exists() |
| | | && |
| | | schemaDir.isDirectory()) |
| | | { |
| | | schemaInstanceDirFiles = schemaDir.listFiles(); |
| | | size += schemaInstanceDirFiles.length; |
| | | } |
| | | } |
| | | |
| | | ArrayList<String> fileList = new ArrayList<String>(size); |
| | | for (File f : schemaInstallDirFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (schemaInstanceDirFiles != null) |
| | | { |
| | | for (File f : schemaInstanceDirFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | fileList.add(f.getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | fileNames = new String[fileList.size()]; |
| | | fileList.toArray(fileNames); |
| | | Arrays.sort(fileNames); |
| | |
| | | import java.awt.Window; |
| | | import java.awt.event.MouseAdapter; |
| | | import java.awt.event.MouseEvent; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.text.CharacterIterator; |
| | |
| | | { |
| | | if (instanceRootDirectory == null) |
| | | { |
| | | String instancePathFileName = installPath + File.separator + |
| | | "instance.loc"; |
| | | |
| | | File f = new File(instancePathFileName); |
| | | // look for <installPath>/instance.loc |
| | | if (! f.exists()) |
| | | { |
| | | instanceRootDirectory = new File(installPath); |
| | | return instanceRootDirectory; |
| | | } |
| | | |
| | | BufferedReader reader; |
| | | try |
| | | { |
| | | reader = new BufferedReader(new FileReader(instancePathFileName)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | instanceRootDirectory = new File(installPath); |
| | | return instanceRootDirectory; |
| | | } |
| | | |
| | | |
| | | // Read the first line and close the file. |
| | | String line; |
| | | try |
| | | { |
| | | line = reader.readLine(); |
| | | File instanceLoc = new File (line); |
| | | if (instanceLoc.isAbsolute()) |
| | | { |
| | | instanceRootDirectory = instanceLoc ; |
| | | return instanceRootDirectory; |
| | | } |
| | | else |
| | | { |
| | | instanceRootDirectory = |
| | | new File(installPath + File.separator + instanceLoc.getPath()); |
| | | return instanceRootDirectory; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | instanceRootDirectory = new File(installPath); |
| | | return instanceRootDirectory; |
| | | } |
| | | finally |
| | | { |
| | | try |
| | | { |
| | | reader.close(); |
| | | } catch (Exception e) {} |
| | | } |
| | | instanceRootDirectory = new File( |
| | | Utils.getInstancePathFromClasspath(installPath)); |
| | | } |
| | | return instanceRootDirectory; |
| | | } |
| | |
| | | schema files that were in place before the start of the restore process have \ |
| | | been preserved and are contained in the %s directory |
| | | SEVERE_ERR_SCHEMA_RESTORE_CANNOT_CREATE_SCHEMA_DIRECTORY_79=Unable to restore \ |
| | | schema backup %s because an error occurred while attempting to create a new \ |
| | | schema backup %s or % s because an error occurred while attempting to create a new \ |
| | | empty directory %s into which the files should be restored: %s |
| | | SEVERE_ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED_80=An error occurred that \ |
| | | prevented the schema backup from being properly restored. The original \ |
| | |
| | | Server schema definitions because the schema directory %s exists but is not a \ |
| | | directory |
| | | SEVERE_ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES_190=Unable to read the Directory \ |
| | | Server schema definitions from directory %s because an unexpected error \ |
| | | Server schema definitions from directory %s or %s because an unexpected error \ |
| | | occurred while trying to list the files in that directory: %s |
| | | SEVERE_WARN_CONFIG_SCHEMA_CANNOT_OPEN_FILE_191=Schema configuration file %s \ |
| | | in directory %s cannot be parsed because an unexpected error occurred while \ |
| | |
| | | %s of task entry %s |
| | | SEVERE_ERR_TASK_ADDSCHEMAFILE_NO_SUCH_FILE_6=Unable to add one or more files \ |
| | | to the server schema because the specified schema file %s does not exist in \ |
| | | schema directory %s |
| | | schema directories %s or %s |
| | | SEVERE_ERR_TASK_ADDSCHEMAFILE_ERROR_CHECKING_FOR_FILE_7=Unable to add one or \ |
| | | more files to the server schema because an error occurred while attempting to \ |
| | | determine whether file %s exists in schema directory %s: %s |
| | | determine whether file %s exists in schema directory %s or %s: %s |
| | | SEVERE_ERR_TASK_ADDSCHEMAFILE_ERROR_LOADING_SCHEMA_FILE_8=An error occurred \ |
| | | while attempting to load the contents of schema file %s into the server \ |
| | | schema: %s |
| | |
| | | the Directory Server at %s on port %s. Check this port is an administration port |
| | | SEVERE_ERR_PWPSTATE_CANNOT_CONNECT_SSL_1629=ERROR: Cannot establish a connection to \ |
| | | the Directory Server at %s on port %s. Check this port is an administration port |
| | | |
| | | INFO_IPATH_PLACEHOLDER_1630={instancePath} |
| | | INFO_CURRENT_USER_PLACEHOLDER_1631={currentUser} |
| | | |
| | | INFO_CONFIGURE_DESCRIPTION_IPATH_1632=Path where the instance will be located |
| | | INFO_CONFIGURE_DESCRIPTION_USERNAME_1633=User name of the owner of the instance |
| | | INFO_CONFIGURE_DESCRIPTION_GROUPNAME_1634=Group name of the owner of the instance |
| | | INFO_CONFIGURE_USAGE_DESCRIPTION_1635=This utility sets the instance location |
| | | SEVERE_ERR_CONFIGURE_NOT_DIRECTORY_1636=[%s] is not a directory. Only directories can \ |
| | | be used as {instancePath} |
| | | SEVERE_ERR_CONFIGURE_DIRECTORY_NOT_EMPTY_1637=[%s] is not empty. Only empty directories can \ |
| | | be used as {instancePath} |
| | | SEVERE_ERR_CONFIGURE_DIRECTORY_NOT_WRITABLE_1638=[%s] is not writable. Cannot create \ |
| | | Directory Server instance |
| | | SEVERE_ERR_CONFIGURE_BAD_USER_NAME_1639=[%s] does not start with a letter. \ |
| | | Cannot be specified as {userName} |
| | | SEVERE_ERR_CONFIGURE_GET_GROUP_ERROR_1640=Unable to retrieve group for [%s]. \ |
| | | Check that [%s] exists |
| | | SEVERE_ERR_CONFIGURE_CHMOD_ERROR_1641=Unable to use [%s]/[%s] as {userName}/{groupName}. \ |
| | | Check that %s exists and belongs to %s |
| | | SEVERE_ERR_CONFIGURE_CURRENT_USER_ERROR_1642=Unauthorized user. \ |
| | | Only user that can write [%s] can use this command |
| | | |
| | | INFO_CHECK_DESCRIPTION_1643=This utility checks version and owner of the instance |
| | | INFO_CHECK_DESCRIPTION_CURRENT_USER_1644=Current user |
| | | INFO_CHECK_DESCRIPTION_CHECK_VERSION_1645=Specifies that check on version should be done |
| | | SEVERE_ERR_CHECK_USER_ERROR_1646=Current user is not owner of the instance. Only [%s] can run this command |
| | | SEVERE_ERR_CHECK_VERSION_NOT_MATCH_1647=Data version does not match binaries. Run upgrade script to solve this |
| | | |
| | | |
| | | SEVERE_ERR_CONFIGURE_USER_NOT_EXIST_1648=User [%s] does not exist |
| | | SEVERE_ERR_CONFIGURE_OPENDSD_NOT_EXIST_1649=User/role [opendsd] does not exist. \ |
| | | Create it or use --userName option to specify another user |
| | | |
| | |
| | | SetupUtils.LIBRARIES_PATH_RELATIVE; |
| | | |
| | | /** |
| | | * The relative path where customer classes are. |
| | | */ |
| | | public static final String CLASSES_PATH_RELATIVE = "classes"; |
| | | |
| | | /** |
| | | * The relative path where the database files are. |
| | | */ |
| | | public static final String DATABASES_PATH_RELATIVE = "db"; |
| | |
| | | CONFIG_PATH_RELATIVE+File.separator+"tools.properties"; |
| | | |
| | | /** |
| | | * The path to the default instance. |
| | | */ |
| | | public static final String DEFAULT_INSTANCE_PATH = "/var/opt/opends"; |
| | | |
| | | /** |
| | | * The relative path to the instance.loc file. |
| | | */ |
| | | public static final String INSTANCE_LOCATION_PATH_RELATIVE = |
| | | "instance.loc"; |
| | | |
| | | /** |
| | | * The path to the instance.loc file. |
| | | */ |
| | | public static final String INSTANCE_LOCATION_PATH = "/etc/opt/opends/" + |
| | | INSTANCE_LOCATION_PATH_RELATIVE; |
| | | |
| | | /** |
| | | * The relative path to tmpl_instance. |
| | | */ |
| | | public static final String TMPL_INSTANCE_RELATIVE_PATH = "tmpl_instance"; |
| | | |
| | | /** |
| | | * The relative path to buildinfo file. |
| | | */ |
| | | public static final String BUILDINFO_RELATIVE_PATH = "buildinfo"; |
| | | |
| | | /** |
| | | * The UNIX setup script file name. |
| | | */ |
| | |
| | | public static final String WINDOWS_UPGRADE_FILE_NAME = "upgrade.bat"; |
| | | |
| | | /** |
| | | * The UNIX configure script file name. |
| | | */ |
| | | public static final String UNIX_CONFIGURE_FILE_NAME = "configure"; |
| | | |
| | | /** |
| | | * Newly upgraded Windows upgrade batch file name. When the upgrade |
| | | * batch file requires upgrade it is not done during execution of the |
| | | * upgrade utility itself since replacing a running script on Windows |
| | |
| | | |
| | | private BuildInformation buildInformation; |
| | | |
| | | private BuildInformation instanceInformation; |
| | | |
| | | /** |
| | | * Indicates if the install and instance are in the same directory. |
| | | * @return true if the install and instance are in the same directory. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the directory of the OpenDS template instance. |
| | | * |
| | | * @return File object representing the top level directory of |
| | | * and OpenDS installation |
| | | */ |
| | | public File getTmplInstanceDirectory() { |
| | | File f = new File(getRootDirectory().getAbsolutePath() + |
| | | File.separator + TMPL_INSTANCE_RELATIVE_PATH ); |
| | | if (f.exists()) |
| | | return f; |
| | | else |
| | | return getInstanceDirectory(); |
| | | } |
| | | |
| | | /** |
| | | * Sets the root directory of this installation. |
| | | * |
| | | * @param rootDirectory File of this installation |
| | |
| | | * @return the path to the tools properties file. |
| | | */ |
| | | public File getToolsPropertiesFile() { |
| | | return new File(getRootDirectory(), TOOLS_PROPERTIES); |
| | | return new File(getTmplInstanceDirectory(), TOOLS_PROPERTIES); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return the path to the set-java-home file. |
| | | */ |
| | | public File getSetJavaHomeFile() { |
| | | return new File(getLibrariesDirectory(), |
| | | return new File(getInstanceDirectory().getAbsolutePath() + File.separator + |
| | | LIBRARIES_PATH_RELATIVE, |
| | | Utils.isWindows()?SET_JAVA_PROPERTIES_FILE_WINDOWS : |
| | | SET_JAVA_PROPERTIES_FILE_UNIX); |
| | | } |
| | |
| | | */ |
| | | public File getBaseSchemaFile() throws ApplicationException { |
| | | return new File(getConfigurationUpgradeDirectory(), |
| | | "schema.ldif." + getInstanceSvnRev().toString()); |
| | | } |
| | | |
| | | /** |
| | | * Creates a File object representing |
| | | * tmpl_instance/config/upgrade/schema.ldif.current. |
| | | * |
| | | * @return File object representing |
| | | * tmpl_instance/config/upgrade/schema.ldif.current |
| | | * @throws ApplicationException if there was a problem determining the |
| | | * svn revision number |
| | | */ |
| | | public File getTemplSchemaFile() throws ApplicationException { |
| | | return new File(getTmplInstanceDirectory().getAbsolutePath() + |
| | | File.separator + CONFIG_PATH_RELATIVE + |
| | | File.separator + UPGRADE_PATH, |
| | | "schema.ldif." + getSvnRev().toString()); |
| | | } |
| | | |
| | | /** |
| | | * Creates a File object representing |
| | | * tmpl_instance/config/upgrade/config.ldif.current. |
| | | * |
| | | * @return File object representing |
| | | * tmpl_instance/config/upgrade/config.ldif.current |
| | | * @throws ApplicationException if there was a problem determining the |
| | | * svn revision number |
| | | */ |
| | | public File getTemplConfigFile() throws ApplicationException { |
| | | return new File(getTmplInstanceDirectory().getAbsolutePath() + |
| | | File.separator + CONFIG_PATH_RELATIVE + |
| | | File.separator + UPGRADE_PATH, |
| | | BASE_CONFIG_FILE_PREFIX + getSvnRev().toString()); |
| | | } |
| | | |
| | | /** |
| | | * Creates a File object representing config/upgrade/schema.ldif.current |
| | | * which the server creates the first time it starts if there are schema |
| | | * customizations. |
| | |
| | | */ |
| | | public File getBaseConfigurationFile() throws ApplicationException { |
| | | return new File(getConfigurationUpgradeDirectory(), |
| | | BASE_CONFIG_FILE_PREFIX + getSvnRev().toString()); |
| | | BASE_CONFIG_FILE_PREFIX + getInstanceSvnRev().toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the SVN revision number of the instance. |
| | | * |
| | | * @return Integer representing the svn number |
| | | * @throws ApplicationException if for some reason the number could not |
| | | * be determined |
| | | */ |
| | | public Integer getInstanceSvnRev() throws ApplicationException { |
| | | BuildInformation bi = getInstanceBuildInformation(); |
| | | return bi.getRevisionNumber(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the path to the configuration file of the directory server. Note |
| | | * that this method assumes that this code is being run locally. |
| | | * |
| | |
| | | * @return the path of the ADS file of the directory server. |
| | | */ |
| | | public File getADSBackendFile() { |
| | | return new File(getRootDirectory(), ADSContext.getAdminLDIFFile()); |
| | | return new File(getTmplInstanceDirectory(), ADSContext.getAdminLDIFFile()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the path to the config files under the instance path. |
| | | * |
| | | * @return the path to the config files under the instance path. |
| | | */ |
| | | public File getInstallConfigurationDirectory() { |
| | | return new File(getRootDirectory(), CONFIG_PATH_RELATIVE); |
| | | } |
| | | |
| | | /** |
| | | * Returns the path to the log files under the install path. |
| | | * |
| | | * @return the path to the log files under the install path. |
| | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * Gets information about the build that was used to produce the |
| | | * instance. |
| | | * @return BuildInformation object describing this instance |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | return Utils.getPath(rootDirectory); |
| | | public BuildInformation getInstanceBuildInformation() { |
| | | return getInstanceBuildInformation(true); |
| | | } |
| | | |
| | | /** |
| | | * Gets information about the build that was used to produce the |
| | | * instance. |
| | | * @param useCachedVersion where true indicates that a potentially cached |
| | | * version of the build information is acceptable for use; false indicates |
| | | * the build information will be created from scratch which is potentially |
| | | * time consuming |
| | | * @return BuildInformation object describing this instance |
| | | */ |
| | | public BuildInformation |
| | | getInstanceBuildInformation(boolean useCachedVersion) { |
| | | if (instanceInformation == null || !useCachedVersion) { |
| | | try { |
| | | File bif = new File(getConfigurationDirectory(), |
| | | BUILDINFO_RELATIVE_PATH); |
| | | |
| | | if (bif.exists()) { |
| | | BufferedReader reader = new BufferedReader(new FileReader(bif)); |
| | | |
| | | // Read the first line and close the file. |
| | | String line; |
| | | try { |
| | | line = reader.readLine(); |
| | | instanceInformation = BuildInformation.fromBuildString(line); |
| | | } finally { |
| | | try { |
| | | reader.close(); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } else { |
| | | return getBuildInformation(); |
| | | } |
| | | } catch (Exception e) { |
| | | LOG.log(Level.SEVERE, "error getting build information for " + |
| | | "current instance", e); |
| | | } |
| | | } |
| | | return instanceInformation; |
| | | |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.quicksetup.configurator; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import org.opends.quicksetup.ReturnCode; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.StringArgument; |
| | | import java.io.InputStreamReader; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import org.opends.messages.Message; |
| | | import org.opends.quicksetup.ApplicationException; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import java.util.StringTokenizer; |
| | | import org.opends.quicksetup.BuildInformation; |
| | | import org.opends.quicksetup.QuickSetupLog; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This class is called by the configure command line to move the default |
| | | * Directory Server instance. |
| | | */ |
| | | public class CheckInstance { |
| | | |
| | | static private final Logger LOG = Logger.getLogger( |
| | | CheckInstance.class.getName()); |
| | | |
| | | /** Prefix for log files. */ |
| | | static public final String LOG_FILE_PREFIX = "opends-checkinstance-"; |
| | | |
| | | private static String installRootFromSystem; |
| | | private static String instanceRootFromSystem; |
| | | /** |
| | | * The user that launches this application. |
| | | */ |
| | | public static final String CURRENT_USER_OPTION_LONG = "currentUser"; |
| | | /** |
| | | * The value for the short option 'currentUser'. |
| | | */ |
| | | public static final Character CURRENT_USER_OPTION_SHORT = null; |
| | | /** |
| | | * Should version be verified. |
| | | */ |
| | | public static final String CHECK_VERSION_OPTION_LONG = "checkVersion"; |
| | | /** |
| | | * The value for the short option 'checkVersion'. |
| | | */ |
| | | public static final Character CHECK_VERSION_OPTION_SHORT = null; |
| | | private static StringArgument currentUserArg; |
| | | private static BooleanArgument checkVersionArg; |
| | | private static String currentUser; |
| | | private static String instanceOwner; |
| | | private static int SUCCESS = 0; |
| | | private static int ARGS_ERROR = 1; |
| | | private static int USER_ERROR = 2; |
| | | private static int VERSION_ERROR = 3; |
| | | |
| | | /** |
| | | * The main method which is called by the configure command lines. |
| | | * |
| | | * @param args the arguments passed by the command line. |
| | | */ |
| | | public static void main(String[] args) { |
| | | |
| | | try { |
| | | QuickSetupLog.initLogFileHandler( |
| | | File.createTempFile(LOG_FILE_PREFIX, |
| | | QuickSetupLog.LOG_FILE_SUFFIX)); |
| | | } catch (Throwable t) { |
| | | System.err.println(INFO_ERROR_INITIALIZING_LOG.get()); |
| | | t.printStackTrace(); |
| | | } |
| | | |
| | | // Create the command-line argument parser for use with this program. |
| | | Message toolDescription = INFO_CHECK_DESCRIPTION.get(); |
| | | ArgumentParser argParser = |
| | | new ArgumentParser(CheckInstance.class.getName(), |
| | | toolDescription, false); |
| | | |
| | | |
| | | installRootFromSystem = System.getProperty("INSTALL_ROOT"); |
| | | if (installRootFromSystem == null) { |
| | | System.err.println("INSTALL_ROOT property not specified"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | instanceRootFromSystem = System.getProperty("INSTANCE_ROOT"); |
| | | if (instanceRootFromSystem == null) { |
| | | System.err.println("INSTANCE_ROOT property not specified"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | // Initialize all the command-line argument types and register them with the |
| | | // parser. |
| | | try { |
| | | currentUserArg = new StringArgument(CURRENT_USER_OPTION_LONG, |
| | | CURRENT_USER_OPTION_SHORT, |
| | | CURRENT_USER_OPTION_LONG, |
| | | true, true, |
| | | INFO_CURRENT_USER_PLACEHOLDER.get(), |
| | | INFO_CHECK_DESCRIPTION_CURRENT_USER.get()); |
| | | argParser.addArgument(currentUserArg); |
| | | checkVersionArg = new BooleanArgument(CHECK_VERSION_OPTION_LONG, |
| | | CHECK_VERSION_OPTION_SHORT, |
| | | CHECK_VERSION_OPTION_LONG, |
| | | INFO_CHECK_DESCRIPTION_CHECK_VERSION.get()); |
| | | argParser.addArgument(checkVersionArg); |
| | | } catch (ArgumentException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | |
| | | // Parse the command-line arguments provided to this program. |
| | | try { |
| | | argParser.parseArguments(args); |
| | | } catch (ArgumentException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | System.exit(ARGS_ERROR); |
| | | } |
| | | |
| | | // Check user |
| | | Installation installation = new Installation(installRootFromSystem, |
| | | instanceRootFromSystem); |
| | | File conf = installation.getCurrentConfigurationFile(); |
| | | String cmd = null; |
| | | Process proc = null; |
| | | int exit = 0; |
| | | |
| | | InputStreamReader reader = null; |
| | | int c; |
| | | StringBuffer sb = new StringBuffer(); |
| | | cmd = "ls -l " + conf.getAbsolutePath(); |
| | | try { |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | reader = new InputStreamReader(proc.getInputStream()); |
| | | while (((c = reader.read()) != -1)) { |
| | | sb.append((char) c); |
| | | } |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.FINEST, cmd + " error= " + exit); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } catch (InterruptedException ex) { |
| | | LOG.log(Level.SEVERE, "InterruptedException" + ex.getMessage()); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } catch (IOException ex) { |
| | | LOG.log(Level.SEVERE, "IOException" + ex.getMessage() ); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | LOG.log(Level.FINEST, cmd + " returns [" + sb.toString() + "]"); |
| | | StringTokenizer tok = new StringTokenizer(sb.toString()); |
| | | if (tok.hasMoreTokens()) { |
| | | // access rights |
| | | tok.nextToken(); |
| | | if (tok.hasMoreTokens()) { |
| | | // inode |
| | | tok.nextToken(); |
| | | if (tok.hasMoreTokens()) { |
| | | instanceOwner = tok.nextToken(); |
| | | LOG.log(Level.FINEST, "instanceOwner=[" + instanceOwner + "]"); |
| | | } else { |
| | | LOG.log(Level.SEVERE, "no instanceOwner"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } else { |
| | | LOG.log(Level.SEVERE, "no inode"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } else { |
| | | LOG.log(Level.SEVERE, "no access rights"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | |
| | | currentUser = currentUserArg.getValue(); |
| | | LOG.log(Level.FINEST, "currentUser=[" + currentUser + "]"); |
| | | |
| | | if ((currentUser != null) && !(currentUser.equals(instanceOwner))) { |
| | | System.err.println(ERR_CHECK_USER_ERROR.get(instanceOwner)); |
| | | System.exit(USER_ERROR); |
| | | } |
| | | |
| | | |
| | | // Check version |
| | | if (checkVersionArg.isPresent()) { |
| | | try { |
| | | BuildInformation installBi = installation.getBuildInformation(); |
| | | BuildInformation instanceBi = installation. |
| | | getInstanceBuildInformation(); |
| | | if (!installBi.equals(instanceBi)) { |
| | | System.err.println(ERR_CHECK_VERSION_NOT_MATCH.get()); |
| | | System.exit(VERSION_ERROR); |
| | | } |
| | | } catch (ApplicationException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } else { |
| | | LOG.log(Level.FINEST, "checkVersion not specified"); |
| | | } |
| | | System.exit(SUCCESS); |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.quicksetup.configurator; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import org.opends.quicksetup.ReturnCode; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.StringArgument; |
| | | import java.io.InputStreamReader; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import org.opends.messages.Message; |
| | | import org.opends.quicksetup.ApplicationException; |
| | | import org.opends.quicksetup.CliApplication; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.Launcher; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.quicksetup.QuickSetupLog; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This class is called by the configure command line to move the default |
| | | * Directory Server instance. |
| | | */ |
| | | public class Configurator extends Launcher { |
| | | |
| | | static private final Logger LOG = Logger.getLogger( |
| | | Configurator.class.getName()); |
| | | |
| | | /** Prefix for log files. */ |
| | | static public final String LOG_FILE_PREFIX = "opends-configure-"; |
| | | |
| | | private String installRootFromSystem; |
| | | |
| | | /** |
| | | * The path where to create the instance. |
| | | */ |
| | | public static final String IPATH_OPTION_LONG = "instancePath"; |
| | | /** |
| | | * The value for the short option 'instancePath'. |
| | | */ |
| | | public static final Character IPATH_OPTION_SHORT = null; |
| | | /** |
| | | * The name of the owner of the instance. |
| | | */ |
| | | public static final String USERNAME_OPTION_LONG = "userName"; |
| | | /** |
| | | * The value for the short option 'userName'. |
| | | */ |
| | | public static final Character USERNAME_OPTION_SHORT = null; |
| | | /** |
| | | * The group of the owner of the instance. |
| | | */ |
| | | public static final String GROUPNAME_OPTION_LONG = "groupName"; |
| | | /** |
| | | * The value for the short option 'groupName'. |
| | | */ |
| | | public static final Character GROUPNAME_OPTION_SHORT = null; |
| | | private ArgumentParser argParser; |
| | | private StringArgument iPath; |
| | | private StringArgument username; |
| | | private StringArgument groupname; |
| | | private BooleanArgument showUsage; |
| | | private String user; |
| | | private String group; |
| | | private String ipath; |
| | | |
| | | /** |
| | | * The main method which is called by the configure command lines. |
| | | * |
| | | * @param args the arguments passed by the command line. |
| | | */ |
| | | public static void main(String[] args) { |
| | | |
| | | try { |
| | | QuickSetupLog.initLogFileHandler( |
| | | File.createTempFile(LOG_FILE_PREFIX, |
| | | QuickSetupLog.LOG_FILE_SUFFIX)); |
| | | } catch (Throwable t) { |
| | | System.err.println(INFO_ERROR_INITIALIZING_LOG.get()); |
| | | t.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | Configurator configurator; |
| | | |
| | | configurator = new Configurator(args); |
| | | configurator.parseArgs(args); |
| | | configurator.configure(); |
| | | |
| | | } catch (ApplicationException ae) { |
| | | LOG.log(Level.SEVERE, "Error during config: " + ae.getMessageObject()); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | |
| | | private void parseArgs(String[] args) { |
| | | |
| | | String cmd = null; |
| | | Process proc = null; |
| | | int exit = 0; |
| | | |
| | | try { |
| | | argParser.parseArguments(args); |
| | | |
| | | if (argParser.usageOrVersionDisplayed()) { |
| | | System.exit(ReturnCode.PRINT_USAGE.getReturnCode()); |
| | | } |
| | | |
| | | /* Check instancePath */ |
| | | if (iPath.hasValue()) { |
| | | ipath = iPath.getValue(); |
| | | } else { |
| | | ipath = Installation.DEFAULT_INSTANCE_PATH; |
| | | } |
| | | File f = new File(ipath); |
| | | if (f.exists()) { |
| | | if (!f.isDirectory()) { |
| | | System.err.println( |
| | | ERR_CONFIGURE_NOT_DIRECTORY.get(ipath)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | File[] l = f.listFiles(); |
| | | if (l.length != 0) { |
| | | System.err.println( |
| | | ERR_CONFIGURE_DIRECTORY_NOT_EMPTY.get(ipath)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | if (!f.canWrite()) { |
| | | System.err.println( |
| | | ERR_CONFIGURE_DIRECTORY_NOT_WRITABLE.get(ipath)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | } else { |
| | | File parent = f; |
| | | |
| | | while ((parent != null) && !parent.exists()) { |
| | | parent = parent.getParentFile(); |
| | | } |
| | | if (parent != null) { |
| | | /* Checks f is writable */ |
| | | if (!parent.canWrite()) { |
| | | System.err.println( |
| | | ERR_CONFIGURE_DIRECTORY_NOT_WRITABLE.get(parent.getName())); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | /* Create subdirs */ |
| | | f.mkdirs(); |
| | | } |
| | | |
| | | /* Check userName/groupName by creating a temporary file and try to |
| | | * set the owner |
| | | */ |
| | | File temp = File.createTempFile(Configurator.class.getName(), null); |
| | | if (username.hasValue()) { |
| | | user = username.getValue(); |
| | | if (! Character.isLetter(user.charAt(0))) { |
| | | System.err.println(ERR_CONFIGURE_BAD_USER_NAME.get(user)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | cmd = "id " + user; |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.err.println(ERR_CONFIGURE_USER_NOT_EXIST.get(user)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } else { |
| | | user = "opendsd"; |
| | | cmd = "id " + user; |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.err.println(ERR_CONFIGURE_OPENDSD_NOT_EXIST.get()); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | |
| | | if (!groupname.hasValue()) { |
| | | InputStreamReader reader = null; |
| | | int c; |
| | | StringBuffer sb = new StringBuffer(); |
| | | cmd = "groups " + user; |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | reader = new InputStreamReader(proc.getInputStream()); |
| | | while (((c = reader.read()) != -1) && (c != ' ')) { |
| | | sb.append((char) c); |
| | | } |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.err.println(ERR_CONFIGURE_GET_GROUP_ERROR.get(user, user)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | group = sb.toString(); |
| | | } else { |
| | | group = groupname.getValue(); |
| | | } |
| | | |
| | | cmd = "chown " + user + ":" + group + " " + temp.getPath(); |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.err.println(ERR_CONFIGURE_CHMOD_ERROR.get(user, group, |
| | | user, group)); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | temp.delete(); |
| | | |
| | | } catch (InterruptedException ex) { |
| | | System.err.println(ex.getLocalizedMessage()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } catch (IOException ex) { |
| | | System.err.println(ex.getLocalizedMessage()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } catch (ArgumentException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void configure() throws ApplicationException { |
| | | File templ_dir = new File(installRootFromSystem + "/" + |
| | | Installation.TMPL_INSTANCE_RELATIVE_PATH); |
| | | |
| | | String cmd = null; |
| | | Process proc = null; |
| | | int exit = 0; |
| | | try { |
| | | /* Copy template instance */ |
| | | File[] l = templ_dir.listFiles(); |
| | | for (int i = 0; i < l.length; i++) { |
| | | File subf = l[i]; |
| | | |
| | | if (subf.isDirectory()) { |
| | | cmd = "cp -R " + l[i].getAbsolutePath() + " " + ipath; |
| | | } else { |
| | | cmd = "cp " + l[i].getAbsolutePath() + " " + ipath; |
| | | } |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | |
| | | /* Change owner */ |
| | | cmd = "chown -R " + user + ":" + group + " " + ipath; |
| | | proc = Runtime.getRuntime().exec(cmd); |
| | | proc.waitFor(); |
| | | exit = proc.exitValue(); |
| | | if (exit != 0) { |
| | | LOG.log(Level.SEVERE, "[" + cmd + "] returns " + exit); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | /* Create instance.loc */ |
| | | File iloc = new File(Installation.INSTANCE_LOCATION_PATH); |
| | | iloc.getParentFile().mkdirs(); |
| | | iloc.createNewFile(); |
| | | FileWriter instanceLoc = new FileWriter(iloc); |
| | | instanceLoc.write(ipath); |
| | | instanceLoc.close(); |
| | | |
| | | } catch (IOException ex) { |
| | | System.err.println(ex.getLocalizedMessage()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } catch (InterruptedException ex) { |
| | | System.err.println(ex.getLocalizedMessage()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | } |
| | | |
| | | private Configurator(String[] args) { |
| | | super(args); |
| | | |
| | | String scriptName = "configure"; |
| | | |
| | | if (Utils.isWindows()) { |
| | | System.err.println("Not supported platform: Windows"); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } else { |
| | | scriptName = Installation.UNIX_CONFIGURE_FILE_NAME; |
| | | } |
| | | if (System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME) == null) { |
| | | System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName); |
| | | } |
| | | |
| | | installRootFromSystem = System.getProperty("INSTALL_ROOT"); |
| | | |
| | | if (installRootFromSystem == null) { |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | |
| | | argParser = new ArgumentParser(getClass().getName(), |
| | | INFO_CONFIGURE_USAGE_DESCRIPTION.get(), false); |
| | | |
| | | |
| | | try { |
| | | iPath = new StringArgument( |
| | | IPATH_OPTION_LONG, |
| | | IPATH_OPTION_SHORT, |
| | | IPATH_OPTION_LONG, |
| | | false, true, |
| | | INFO_IPATH_PLACEHOLDER.get(), |
| | | INFO_CONFIGURE_DESCRIPTION_IPATH.get()); |
| | | argParser.addArgument(iPath); |
| | | |
| | | username = |
| | | new StringArgument( |
| | | USERNAME_OPTION_LONG, |
| | | USERNAME_OPTION_SHORT, |
| | | USERNAME_OPTION_LONG, |
| | | false, true, |
| | | INFO_USER_NAME_PLACEHOLDER.get(), |
| | | INFO_CONFIGURE_DESCRIPTION_USERNAME.get()); |
| | | argParser.addArgument(username); |
| | | |
| | | groupname = |
| | | new StringArgument( |
| | | GROUPNAME_OPTION_LONG, |
| | | GROUPNAME_OPTION_SHORT, |
| | | GROUPNAME_OPTION_LONG, |
| | | false, true, |
| | | INFO_GROUPNAME_PLACEHOLDER.get(), |
| | | INFO_CONFIGURE_DESCRIPTION_GROUPNAME.get()); |
| | | argParser.addArgument(groupname); |
| | | |
| | | showUsage = new BooleanArgument( |
| | | "showusage", |
| | | OPTION_SHORT_HELP, |
| | | OPTION_LONG_HELP, |
| | | INFO_DESCRIPTION_USAGE.get()); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | |
| | | } catch (ArgumentException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected void willLaunchGui() { |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected void guiLaunchFailed(String logFilePath) { |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected CliApplication createCliApplication() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Message getFrameTitle() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ArgumentParser getArgumentParser() { |
| | | return argParser; |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | /** |
| | | * Defines the specific classes that are used by the configurator. |
| | | */ |
| | | package org.opends.quicksetup.configurator; |
| | |
| | | writer.close(); |
| | | } |
| | | String destinationFile; |
| | | String libDir = Utils.getPath(installPath, |
| | | String libDir = Utils.getPath(Utils. |
| | | getInstancePathFromClasspath(installPath), |
| | | Installation.LIBRARIES_PATH_RELATIVE); |
| | | if (Utils.isWindows()) |
| | | { |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.upgrader; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.quicksetup.CliApplication; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.QuickSetupLog; |
| | | import org.opends.quicksetup.ReturnCode; |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import java.util.logging.Logger; |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * This class is called by the upgrade and upgrade.bat |
| | | * command line utilities to launch an upgrade process. |
| | | */ |
| | | public class UpgradeSvr4Launcher extends UpgradeLauncher { |
| | | |
| | | static private final Logger LOG = |
| | | Logger.getLogger(UpgradeSvr4Launcher.class.getName()); |
| | | |
| | | /** |
| | | * The main method which is called by the setup command lines. |
| | | * |
| | | * @param args the arguments passed by the command lines. |
| | | */ |
| | | public static void main(String[] args) { |
| | | try { |
| | | QuickSetupLog.initLogFileHandler( |
| | | File.createTempFile(LOG_FILE_PREFIX, |
| | | QuickSetupLog.LOG_FILE_SUFFIX)); |
| | | } catch (Throwable t) { |
| | | System.err.println(INFO_ERROR_INITIALIZING_LOG.get()); |
| | | t.printStackTrace(); |
| | | } |
| | | new UpgradeSvr4Launcher(args).launch(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected CliApplication createCliApplication() { |
| | | return new UpgraderSvr4(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected void willLaunchGui() { |
| | | System.out.println(INFO_UPGRADE_LAUNCHER_LAUNCHING_GUI.get()); |
| | | System.setProperty("org.opends.quicksetup.Application.class", |
| | | "org.opends.quicksetup.upgrader.UpgraderSvr4"); |
| | | } |
| | | |
| | | private ArgumentParser argParser; |
| | | |
| | | private BooleanArgument showUsage; |
| | | private BooleanArgument quiet; |
| | | private BooleanArgument noPrompt; |
| | | private BooleanArgument verbose; |
| | | private BooleanArgument revertMostRecent; |
| | | private StringArgument reversionArchive; |
| | | |
| | | |
| | | /** |
| | | * Creates an instance. |
| | | * |
| | | * @param args specified on command line |
| | | */ |
| | | protected UpgradeSvr4Launcher(String[] args) { |
| | | super(args); |
| | | |
| | | String scriptName; |
| | | if (Utils.isWindows()) { |
| | | scriptName = Installation.WINDOWS_UPGRADE_FILE_NAME; |
| | | } else { |
| | | scriptName = Installation.UNIX_UPGRADE_FILE_NAME; |
| | | } |
| | | if (System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME) == null) |
| | | { |
| | | System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName); |
| | | } |
| | | |
| | | argParser = new ArgumentParser(getClass().getName(), |
| | | INFO_UPGRADE_LAUNCHER_USAGE_DESCRIPTION.get(), false); |
| | | try |
| | | { |
| | | revertMostRecent = new BooleanArgument( |
| | | REVERT_MOST_RECENT_OPTION_LONG, |
| | | REVERT_MOST_RECENT_OPTION_SHORT, |
| | | REVERT_MOST_RECENT_OPTION_LONG, |
| | | INFO_REVERT_DESCRIPTION_RECENT.get()); |
| | | argParser.addArgument(revertMostRecent); |
| | | |
| | | reversionArchive = new StringArgument( |
| | | REVERT_ARCHIVE_OPTION_LONG, |
| | | REVERT_ARCHIVE_OPTION_SHORT, |
| | | REVERT_ARCHIVE_OPTION_LONG, |
| | | false, false, true, |
| | | INFO_DIRECTORY_PLACEHOLDER.get(), |
| | | null, null, INFO_REVERT_DESCRIPTION_DIRECTORY.get()); |
| | | argParser.addArgument(reversionArchive); |
| | | |
| | | noPrompt = new BooleanArgument( |
| | | OPTION_LONG_NO_PROMPT, |
| | | OPTION_SHORT_NO_PROMPT, |
| | | OPTION_LONG_NO_PROMPT, |
| | | INFO_UPGRADE_DESCRIPTION_NO_PROMPT.get()); |
| | | argParser.addArgument(noPrompt); |
| | | |
| | | quiet = new BooleanArgument( |
| | | OPTION_LONG_QUIET, |
| | | OPTION_SHORT_QUIET, |
| | | OPTION_LONG_QUIET, |
| | | INFO_UPGRADE_DESCRIPTION_SILENT.get()); |
| | | argParser.addArgument(quiet); |
| | | |
| | | verbose = new BooleanArgument(OPTION_LONG_VERBOSE, OPTION_SHORT_VERBOSE, |
| | | OPTION_LONG_VERBOSE, INFO_DESCRIPTION_VERBOSE.get()); |
| | | argParser.addArgument(verbose); |
| | | |
| | | showUsage = new BooleanArgument( |
| | | "showusage", |
| | | OPTION_SHORT_HELP, |
| | | OPTION_LONG_HELP, |
| | | INFO_DESCRIPTION_USAGE.get()); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | |
| | | try { |
| | | argParser.parseArguments(args); |
| | | |
| | | // Set fields indicating reversion or upgrade. This may change |
| | | // later if interaction is required to make the determination. |
| | | isReversion = |
| | | reversionArchive.isPresent() || revertMostRecent.isPresent(); |
| | | isUpgrade = !isReversion; |
| | | |
| | | if (argParser.usageOrVersionDisplayed()) { |
| | | System.exit(ReturnCode.PRINT_USAGE.getReturnCode()); |
| | | } |
| | | } catch (ArgumentException ae) { |
| | | System.err.println(ae.getMessageObject()); |
| | | printUsage(false); |
| | | System.exit(ReturnCode. |
| | | APPLICATION_ERROR.getReturnCode()); |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | System.out.println("ERROR: "+t); |
| | | t.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.tools.JavaPropertiesTool; |
| | | |
| | | import java.awt.event.WindowEvent; |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileFilter; |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | "bin", |
| | | "lib", |
| | | "bat", |
| | | "config" + File.separator + "schema", |
| | | "setup", |
| | | "setup.bat", |
| | | "uninstall", |
| | |
| | | /** |
| | | * Information on the current build. |
| | | */ |
| | | private BuildInformation currentVersion = null; |
| | | protected BuildInformation currentVersion = null; |
| | | |
| | | /** |
| | | * Information on the current instance. |
| | | */ |
| | | protected BuildInformation currentInstanceVersion = null; |
| | | |
| | | /** |
| | | * Information on the staged build. |
| | |
| | | private BuildInformation stagedVersion = null; |
| | | |
| | | /** |
| | | * Information on the staged instance. |
| | | */ |
| | | private BuildInformation stagedInstanceVersion = null; |
| | | |
| | | /** |
| | | * New OpenDS bits. |
| | | */ |
| | | private Installation stagedInstallation = null; |
| | |
| | | return null; |
| | | } |
| | | |
| | | String instancePathFileName = installPath + File.separator + "instance.loc"; |
| | | |
| | | // look for <installPath>/instance.loc |
| | | File f = new File(instancePathFileName); |
| | | if (!f.exists()) |
| | | { |
| | | return installPath; |
| | | } |
| | | |
| | | BufferedReader reader; |
| | | try |
| | | { |
| | | reader = new BufferedReader(new FileReader(instancePathFileName)); |
| | | } catch (Exception e) |
| | | { |
| | | return installPath; |
| | | } |
| | | |
| | | // Read the first line and close the file. |
| | | String line; |
| | | try |
| | | { |
| | | line = reader.readLine(); |
| | | File instanceLoc = new File(line); |
| | | if (instanceLoc.isAbsolute()) |
| | | { |
| | | return instanceLoc.getAbsolutePath(); |
| | | } else |
| | | { |
| | | return new File(installPath + File.separator |
| | | + line).getAbsolutePath(); |
| | | } |
| | | } catch (Exception e) |
| | | { |
| | | return installPath; |
| | | } finally |
| | | { |
| | | try |
| | | { |
| | | reader.close(); |
| | | } catch (Exception e) |
| | | { |
| | | } |
| | | } |
| | | return Utils.getInstancePathFromClasspath(installPath); |
| | | } |
| | | |
| | | /** |
| | |
| | | UpgradeProgressStep.UPGRADING_COMPONENTS); |
| | | upgradeComponents(); |
| | | updateConfigDirectory(); |
| | | updateExtensionsDirectory(); |
| | | notifyListeners(getFormattedDoneWithLineBreak()); |
| | | LOG.log(Level.INFO, "component upgrade finished"); |
| | | } catch (ApplicationException e) { |
| | |
| | | |
| | | } |
| | | |
| | | private Stage getStage() throws IOException, ApplicationException { |
| | | /** |
| | | * Returns the directory used to stage files for upgrade or reversion. |
| | | * @return the directory used to stage files for upgrade or reversion |
| | | * @throws IOException if errors occurs while accessing stage files |
| | | * @throws org.opends.quicksetup.ApplicationException |
| | | * if retrieval of stage files path fails |
| | | */ |
| | | protected Stage getStage() throws IOException, ApplicationException { |
| | | if (this.stage == null) { |
| | | this.stage = new Stage(getStageDirectory()); |
| | | } |
| | | return this.stage; |
| | | } |
| | | |
| | | private void upgradeComponents() throws ApplicationException { |
| | | /** |
| | | * Upgrade components. |
| | | * @throws ApplicationException if upgrade fails |
| | | */ |
| | | protected void upgradeComponents() throws ApplicationException { |
| | | try { |
| | | Stage stage = getStage(); |
| | | Installation installation = getInstallation(); |
| | |
| | | else |
| | | { |
| | | stage.move(root, new UpgradeFileFilter(getStageDirectory(),true)); |
| | | |
| | | root = installation.getInstanceDirectory(); |
| | | stage.move(root, new UpgradeFileFilter(getStageDirectory(),false)); |
| | | } |
| | | |
| | | // Check if instance.loc exits |
| | | File instanceFile = new File |
| | | (installation.getRootDirectory(), "instance.loc"); |
| | | (installation.getRootDirectory(), |
| | | Installation.INSTANCE_LOCATION_PATH_RELATIVE); |
| | | if (! instanceFile.exists()) |
| | | { |
| | | BufferedWriter instanceLoc = |
| | |
| | | { |
| | | // The config directory may contain files that are needed |
| | | // by the new installation (e.g. SSL config files and tasks) |
| | | File oldConfigDir = |
| | | File oldInstallConfigDir = |
| | | new File(getFilesInstallBackupDirectory(), |
| | | Installation.CONFIG_PATH_RELATIVE); |
| | | File oldInstanceConfigDir = |
| | | new File(getFilesInstanceBackupDirectory(), |
| | | Installation.CONFIG_PATH_RELATIVE); |
| | | File newConfigDir = |
| | | File newInstallConfigDir = |
| | | getInstallation().getInstallConfigurationDirectory(); |
| | | File newInstanceConfigDir = |
| | | getInstallation().getConfigurationDirectory(); |
| | | FileManager fm = new FileManager(); |
| | | |
| | | // Define a filter for files that we don't want to copy over |
| | | // from the old config directory. |
| | | final File oldConfigUpgradeDir = new File(oldConfigDir, "upgrade"); |
| | | final File oldConfigSchemaDir = new File(oldConfigDir, "schema"); |
| | | FileFilter filter = new FileFilter() { |
| | | public boolean accept(File f) { |
| | | return !Utils.isDescendant(f, oldConfigUpgradeDir) && |
| | | !Utils.isDescendant(f, oldConfigSchemaDir); |
| | | { |
| | | final File oldConfigUpgradeDir = new File(oldInstallConfigDir, "upgrade"); |
| | | final File oldConfigSchemaDir = new File(oldInstallConfigDir, "schema"); |
| | | FileFilter filter = new FileFilter() |
| | | { |
| | | public boolean accept(File f) |
| | | { |
| | | return !Utils.isDescendant(f, oldConfigUpgradeDir) |
| | | && !Utils.isDescendant(f, oldConfigSchemaDir); |
| | | } |
| | | }; |
| | | |
| | | fm.synchronize(oldConfigDir, newConfigDir, filter); |
| | | fm.synchronize(oldInstallConfigDir, newInstallConfigDir, filter); |
| | | } |
| | | |
| | | private void backupFilesystem() throws ApplicationException { |
| | | { |
| | | final File oldConfigUpgradeDir = |
| | | new File(oldInstanceConfigDir, "upgrade"); |
| | | FileFilter filter = new FileFilter() |
| | | { |
| | | public boolean accept(File f) |
| | | { |
| | | return !Utils.isDescendant(f, oldConfigUpgradeDir); |
| | | } |
| | | }; |
| | | |
| | | fm.synchronize(oldInstanceConfigDir, newInstanceConfigDir, filter); |
| | | } |
| | | } |
| | | |
| | | private void updateExtensionsDirectory() |
| | | throws IOException,ApplicationException |
| | | { |
| | | // Get extensions back |
| | | File savedDir = |
| | | new File(getFilesInstanceBackupDirectory(), |
| | | Installation.LIBRARIES_PATH_RELATIVE); |
| | | File destDir = getInstallation().getInstanceDirectory(); |
| | | |
| | | FileManager fm = new FileManager(); |
| | | fm.copyRecursively(savedDir, destDir); |
| | | |
| | | // Get classes back |
| | | savedDir = |
| | | new File(getFilesInstanceBackupDirectory(), |
| | | Installation.CLASSES_PATH_RELATIVE); |
| | | destDir = getInstallation().getInstanceDirectory(); |
| | | |
| | | fm.copyRecursively(savedDir, destDir); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Backup files to be able to revert if upgrdae fails. |
| | | * @throws ApplicationException if backup fails |
| | | */ |
| | | protected void backupFilesystem() throws ApplicationException { |
| | | try { |
| | | // Backup first install (potentially everything if install and instance |
| | | // are in the same dir |
| | |
| | | } |
| | | } |
| | | |
| | | private void cleanup() throws ApplicationException { |
| | | /** |
| | | * Cleanup to done executed once upgrade is done. |
| | | * @throws org.opends.quicksetup.ApplicationException |
| | | * if cleanup fails |
| | | */ |
| | | protected void cleanup() throws ApplicationException { |
| | | deleteStagingDirectory(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void initialize() throws ApplicationException { |
| | | /** |
| | | * Implements the initialization phase of the upgrade. |
| | | * @throws ApplicationException if upgrade is not possible |
| | | */ |
| | | protected void initialize() throws ApplicationException { |
| | | try { |
| | | BuildInformation fromVersion = getCurrentBuildInformation(); |
| | | BuildInformation fromVersion = getCurrentInstanceBuildInformation(); |
| | | BuildInformation toVersion = getStagedBuildInformation(); |
| | | if (fromVersion.equals(toVersion)) |
| | | { |
| | | throw new ApplicationException(ReturnCode.APPLICATION_ERROR, |
| | | INFO_UPGRADE_ORACLE_SAME_VERSION.get( |
| | | fromVersion.toString()), null); |
| | | toVersion.toString()), null); |
| | | } |
| | | if (getInstallation().getStatus().isServerRunning()) { |
| | | new ServerController(getInstallation()).stopServer(true); |
| | |
| | | * cannot be insured. |
| | | */ |
| | | private void insureUpgradability() throws ApplicationException { |
| | | BuildInformation currentVersion; |
| | | BuildInformation newVersion; |
| | | try { |
| | | currentVersion = getInstallation().getBuildInformation(); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "error getting build information for " + |
| | | "current installation", e); |
| | | throw ApplicationException.createFileSystemException( |
| | | INFO_ERROR_DETERMINING_CURRENT_BUILD.get(), e); |
| | | } |
| | | currentVersion = getCurrentInstanceBuildInformation(); |
| | | |
| | | try { |
| | | newVersion = getStagedInstallation().getBuildInformation(); |
| | |
| | | } |
| | | } |
| | | |
| | | private Installation getStagedInstallation() |
| | | /** |
| | | * Returns the path of the new OpenDS bits. |
| | | * @return the path of the new OpenDS bits. |
| | | * @throws java.io.IOException if an error occurs while accessing the |
| | | * new bits |
| | | * @throws org.opends.quicksetup.ApplicationException if upgradability |
| | | * cannot be insured. |
| | | */ |
| | | protected Installation getStagedInstallation() |
| | | throws IOException, ApplicationException { |
| | | if (stagedInstallation == null) { |
| | | File stageDir = getStageDirectory(); |
| | |
| | | return txt; |
| | | } |
| | | |
| | | private File getStageDirectory() |
| | | /** |
| | | * Returns the path of the new OpenDS bits. |
| | | * @return the path of the new OpenDS bits. |
| | | * @throws org.opends.quicksetup.ApplicationException |
| | | * if retrieval of stage files path fails |
| | | * @throws java.io.IOException if errors occurs while accessing stage files |
| | | */ |
| | | protected File getStageDirectory() |
| | | throws ApplicationException, IOException { |
| | | return getInstallation().getTemporaryUpgradeDirectory(); |
| | | } |
| | |
| | | return installDir.getAbsolutePath().equals(instanceDir.getAbsolutePath()); |
| | | } |
| | | |
| | | private File getFilesInstanceBackupDirectory() throws IOException |
| | | /** |
| | | * Returns the path where to backup instance files. |
| | | * @return the path where to backup instance files. |
| | | * @throws java.io.IOException if retrieval of backup files fails |
| | | */ |
| | | protected File getFilesInstanceBackupDirectory() throws IOException |
| | | { |
| | | if (instanceAndInstallInSameDir()) |
| | | { |
| | |
| | | return backupDirectory; |
| | | } |
| | | |
| | | /** |
| | | * Returns the BuildInformation of the current OpenDS bits. |
| | | * @return the BuildInformation of the current OpenDS bits. |
| | | */ |
| | | private BuildInformation getCurrentBuildInformation() { |
| | | if (this.currentVersion == null) { |
| | | try { |
| | |
| | | return currentVersion; |
| | | } |
| | | |
| | | /** |
| | | * Returns the BuildInformation of the OpenDS instance. |
| | | * @return the BuildInformation of the OpenDS instance. |
| | | */ |
| | | private BuildInformation getCurrentInstanceBuildInformation() { |
| | | if (this.currentInstanceVersion == null) { |
| | | currentInstanceVersion = getInstallation().getInstanceBuildInformation(); |
| | | } |
| | | |
| | | return currentInstanceVersion; |
| | | } |
| | | |
| | | |
| | | private BuildInformation getStagedBuildInformation() { |
| | | if (stagedVersion == null) { |
| | | try { |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.quicksetup.upgrader; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | |
| | | import org.opends.quicksetup.ApplicationException; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.Launcher; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.UserDataException; |
| | | import org.opends.quicksetup.util.FileManager; |
| | | import java.io.FileFilter; |
| | | import org.opends.quicksetup.ReturnCode; |
| | | |
| | | /** |
| | | * QuickSetup application of upgrading the bits of an SVR4 based installation |
| | | * of OpenDS. |
| | | */ |
| | | public class UpgraderSvr4 extends Upgrader { |
| | | |
| | | static private final Logger LOG = Logger.getLogger( |
| | | UpgraderSvr4.class.getName()); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public UserData createUserData(Launcher launcher) |
| | | throws UserDataException { |
| | | return new UpgraderCliHelper((UpgradeSvr4Launcher) launcher). |
| | | createUserData(launcher.getArguments()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected File getStageDirectory() |
| | | throws ApplicationException, IOException { |
| | | return getInstallation().getTmplInstanceDirectory(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected Installation getStagedInstallation() |
| | | throws IOException, ApplicationException { |
| | | /* New bits have replaced old */ |
| | | return getInstallation(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected void cleanup() throws ApplicationException { |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected void backupFilesystem() throws ApplicationException { |
| | | try { |
| | | FileManager fm = new FileManager(); |
| | | File filesBackupDirectory = getFilesInstanceBackupDirectory(); |
| | | File root = getInstallation().getInstanceDirectory(); |
| | | FileFilter filter = new UpgradeFileFilter(root, false); |
| | | for (String fileName : root.list()) { |
| | | File f = new File(root, fileName); |
| | | fm.move(f, filesBackupDirectory, filter); |
| | | } |
| | | } catch (ApplicationException ae) { |
| | | throw ae; |
| | | } catch (Exception e) { |
| | | throw new ApplicationException( |
| | | ReturnCode.FILE_SYSTEM_ACCESS_ERROR, |
| | | INFO_ERROR_BACKUP_FILESYSTEM.get(), |
| | | e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected void upgradeComponents() throws ApplicationException { |
| | | try { |
| | | /* Only instance data have to be upgraded */ |
| | | Stage stage = getStage(); |
| | | Installation installation = getInstallation(); |
| | | File root = installation.getInstanceDirectory(); |
| | | stage.move(root, new UpgradeFileFilter(getStageDirectory(), false)); |
| | | |
| | | LOG.log(Level.INFO, "upgraded bits to " + |
| | | installation.getBuildInformation(false)); |
| | | |
| | | } catch (IOException e) { |
| | | throw ApplicationException.createFileSystemException( |
| | | INFO_ERROR_UPGRADING_COMPONENTS.get(), e); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public static String getInstancePathFromClasspath(String installPath) |
| | | { |
| | | String instancePathFileName = installPath + File.separator + "instance.loc"; |
| | | String instancePathFileName = Installation.INSTANCE_LOCATION_PATH; |
| | | File configureScriptPath = new File(installPath + File.separator + |
| | | Installation.UNIX_CONFIGURE_FILE_NAME); |
| | | |
| | | // look for <installPath>/instance.loc |
| | | // look for /etc/opt/opends/instance.loc |
| | | File f = new File(instancePathFileName); |
| | | if (! f.exists()) |
| | | { |
| | | if (!configureScriptPath.exists() || !f.exists()) { |
| | | // look for <installPath>/instance.loc |
| | | instancePathFileName = installPath + File.separator + |
| | | Installation.INSTANCE_LOCATION_PATH_RELATIVE; |
| | | f = new File(instancePathFileName); |
| | | if (!f.exists()) { |
| | | return installPath; |
| | | } |
| | | } |
| | | |
| | | BufferedReader reader; |
| | | try |
| | |
| | | |
| | | // Put extensions jars into the class loader and load all |
| | | // configuration definition classes in that they contain. |
| | | initializeAllExtensions(); |
| | | // First load the extension from the install directory, then |
| | | // from the instance directory. |
| | | File libDir ; |
| | | File extensionsPath ; |
| | | |
| | | libDir = new File(DirectoryServer.getServerRoot(),LIB_DIR); |
| | | extensionsPath = new File(libDir, EXTENSIONS_DIR); |
| | | initializeAllExtensions(extensionsPath); |
| | | |
| | | libDir = new File(DirectoryServer.getInstanceRoot(),LIB_DIR); |
| | | extensionsPath = new File(libDir, EXTENSIONS_DIR); |
| | | initializeAllExtensions(extensionsPath); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Put extensions jars into the class loader and load all |
| | | * configuration definition classes in that they contain. |
| | | * @param extensionsPath Indicates where extensions are located. |
| | | * |
| | | * @throws InitializationException |
| | | * If the extensions folder could not be accessed or if a |
| | |
| | | * the configuration definition classes could not be |
| | | * initialized. |
| | | */ |
| | | private void initializeAllExtensions() |
| | | private void initializeAllExtensions(File extensionsPath) |
| | | throws InitializationException { |
| | | File libPath = new File(DirectoryServer.getInstanceRoot(), LIB_DIR); |
| | | File extensionsPath = new File(libPath, EXTENSIONS_DIR); |
| | | |
| | | try { |
| | | if (!extensionsPath.exists()) { |
| | |
| | | ArrayList<File> tempFileList = new ArrayList<File>(); |
| | | ArrayList<File> origFileList = new ArrayList<File>(); |
| | | |
| | | File schemaDir = new File(SchemaConfigManager.getSchemaDirectoryPath()); |
| | | File schemaInstallDir = |
| | | new File(SchemaConfigManager.getSchemaDirectoryPath(false)); |
| | | File schemaInstanceDir = |
| | | new File(SchemaConfigManager.getSchemaDirectoryPath(true)); |
| | | |
| | | for (String name : tempSchemaFiles.keySet()) |
| | | { |
| | | installedFileList.add(new File(schemaDir, name)); |
| | | File installFile = new File(schemaInstallDir, name); |
| | | if (installFile.exists()) |
| | | { |
| | | installedFileList.add(installFile); |
| | | } else |
| | | { |
| | | installedFileList.add(new File(schemaInstanceDir, name)); |
| | | } |
| | | tempFileList.add(tempSchemaFiles.get(name)); |
| | | origFileList.add(new File(schemaDir, name + ".orig")); |
| | | origFileList.add(new File(schemaInstanceDir, name + ".orig")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // Get the path to the directory in which the schema files reside and |
| | | // then get a list of all the files in that directory. |
| | | String schemaDirPath = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | File[] schemaFiles; |
| | | String schemaInstallDirPath = |
| | | SchemaConfigManager.getSchemaDirectoryPath(false); |
| | | String schemaInstanceDirPath = |
| | | SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | File[][] schemaFiles = new File[2][]; |
| | | try |
| | | { |
| | | File schemaDir = new File(schemaDirPath); |
| | | schemaFiles = schemaDir.listFiles(); |
| | | File schemaDir = new File(schemaInstallDirPath); |
| | | schemaFiles[0] = schemaDir.listFiles(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | message = ERR_SCHEMA_BACKUP_CANNOT_LIST_SCHEMA_FILES.get( |
| | | schemaDirPath, getExceptionMessage(e)); |
| | | schemaInstallDirPath, getExceptionMessage(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | |
| | | try |
| | | { |
| | | File schemaDir = new File(schemaInstanceDirPath); |
| | | schemaFiles[1] = schemaDir.listFiles(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | schemaFiles[1] = new File[0] ; |
| | | } |
| | | |
| | | // Iterate through the schema files and write them to the zip stream. If |
| | | // we're using a hash or MAC, then calculate that as well. |
| | | byte[] buffer = new byte[8192]; |
| | | for (File schemaFile : schemaFiles) |
| | | String parent = ".install"; |
| | | for (int i=0 ; i < 2 ; i++) |
| | | { |
| | | for (File schemaFile : schemaFiles[i]) |
| | | { |
| | | if (backupConfig.isCancelled()) |
| | | { |
| | |
| | | |
| | | String baseName = schemaFile.getName(); |
| | | |
| | | |
| | | // We'll put the name in the hash, too. |
| | | if (hash) |
| | | { |
| | | if (signHash) |
| | | { |
| | | mac.update(getBytes(baseName)); |
| | | } |
| | | else |
| | | } else |
| | | { |
| | | digest.update(getBytes(baseName)); |
| | | } |
| | |
| | | InputStream inputStream = null; |
| | | try |
| | | { |
| | | ZipEntry zipEntry = new ZipEntry(baseName); |
| | | ZipEntry zipEntry = new ZipEntry(baseName + parent); |
| | | zipStream.putNextEntry(zipEntry); |
| | | |
| | | inputStream = new FileInputStream(schemaFile); |
| | |
| | | if (signHash) |
| | | { |
| | | mac.update(buffer, 0, bytesRead); |
| | | } |
| | | else |
| | | } else |
| | | { |
| | | digest.update(buffer, 0, bytesRead); |
| | | } |
| | |
| | | |
| | | zipStream.closeEntry(); |
| | | inputStream.close(); |
| | | } |
| | | catch (Exception e) |
| | | } catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | |
| | | try |
| | | { |
| | | inputStream.close(); |
| | | } catch (Exception e2) {} |
| | | } catch (Exception e2) |
| | | { |
| | | } |
| | | |
| | | try |
| | | { |
| | | zipStream.close(); |
| | | } catch (Exception e2) {} |
| | | |
| | | message = ERR_SCHEMA_BACKUP_CANNOT_BACKUP_SCHEMA_FILE.get( |
| | | baseName, stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } catch (Exception e2) |
| | | { |
| | | } |
| | | |
| | | message = ERR_SCHEMA_BACKUP_CANNOT_BACKUP_SCHEMA_FILE.get(baseName, |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer |
| | | .getServerErrorResultCode(), message, e); |
| | | } |
| | | } |
| | | parent = ".instance"; |
| | | } |
| | | |
| | | |
| | |
| | | // try to verify the archive. If we are not going to verify only, then |
| | | // move the current schema directory out of the way so we can keep it around |
| | | // to restore if a problem occurs. |
| | | String schemaDirPath = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | File schemaDir = new File(schemaDirPath); |
| | | String backupDirPath = null; |
| | | File schemaBackupDir = null; |
| | | String schemaInstallDirPath = |
| | | SchemaConfigManager.getSchemaDirectoryPath(false); |
| | | String schemaInstanceDirPath = |
| | | SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | File schemaInstallDir = new File(schemaInstallDirPath); |
| | | File schemaInstanceDir = new File(schemaInstanceDirPath); |
| | | |
| | | String backupInstallDirPath = null; |
| | | File schemaBackupInstallDir = null; |
| | | |
| | | String backupInstanceDirPath = null; |
| | | File schemaBackupInstanceDir = null; |
| | | boolean verifyOnly = restoreConfig.verifyOnly(); |
| | | if (! verifyOnly) |
| | | { |
| | | // Rename the current schema directory if it exists. |
| | | try |
| | | { |
| | | if (schemaDir.exists()) |
| | | if (schemaInstallDir.exists()) |
| | | { |
| | | String schemaBackupDirPath = schemaDirPath + ".save"; |
| | | backupDirPath = schemaBackupDirPath; |
| | | schemaBackupDir = new File(backupDirPath); |
| | | if (schemaBackupDir.exists()) |
| | | String schemaBackupInstallDirPath = schemaInstallDirPath + ".save"; |
| | | backupInstallDirPath = schemaBackupInstallDirPath; |
| | | schemaBackupInstallDir = new File(backupInstallDirPath); |
| | | if (schemaBackupInstallDir.exists()) |
| | | { |
| | | int i=2; |
| | | while (true) |
| | | { |
| | | backupDirPath = schemaBackupDirPath + i; |
| | | schemaBackupDir = new File(backupDirPath); |
| | | if (schemaBackupDir.exists()) |
| | | backupInstallDirPath = schemaBackupInstallDirPath + i; |
| | | schemaBackupInstallDir = new File(backupInstallDirPath); |
| | | if (schemaBackupInstallDir.exists()) |
| | | { |
| | | i++; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | schemaDir.renameTo(schemaBackupDir); |
| | | schemaInstallDir.renameTo(schemaBackupInstallDir); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_CANNOT_RENAME_CURRENT_DIRECTORY. |
| | | get(backupID, schemaDirPath, String.valueOf(backupDirPath), |
| | | get(backupID, schemaInstallDirPath, |
| | | String.valueOf(backupInstallDirPath), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | try |
| | | { |
| | | if (schemaInstanceDir.exists()) |
| | | { |
| | | String schemaBackupInstanceDirPath = schemaInstanceDirPath + ".save"; |
| | | backupInstanceDirPath = schemaBackupInstanceDirPath; |
| | | schemaBackupInstanceDir = new File(backupInstanceDirPath); |
| | | if (schemaBackupInstanceDir.exists()) |
| | | { |
| | | int i=2; |
| | | while (true) |
| | | { |
| | | backupInstanceDirPath = schemaBackupInstanceDirPath + i; |
| | | schemaBackupInstanceDir = new File(backupInstanceDirPath); |
| | | if (schemaBackupInstanceDir.exists()) |
| | | { |
| | | i++; |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | schemaInstanceDir.renameTo(schemaBackupInstanceDir); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_CANNOT_RENAME_CURRENT_DIRECTORY. |
| | | get(backupID, schemaInstanceDirPath, |
| | | String.valueOf(backupInstanceDirPath), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | |
| | | // Create a new directory to hold the restored schema files. |
| | | try |
| | | { |
| | | schemaDir.mkdirs(); |
| | | schemaInstallDir.mkdirs(); |
| | | schemaInstanceDir.mkdirs(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Try to restore the previous schema directory if possible. This will |
| | | // probably fail in this case, but try anyway. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | try |
| | | { |
| | | schemaBackupDir.renameTo(schemaDir); |
| | | schemaBackupInstallDir.renameTo(schemaInstallDir); |
| | | Message message = |
| | | NOTE_SCHEMA_RESTORE_RESTORED_OLD_SCHEMA.get(schemaDirPath); |
| | | NOTE_SCHEMA_RESTORE_RESTORED_OLD_SCHEMA.get( |
| | | schemaInstallDirPath); |
| | | logError(message); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_CANNOT_RESTORE_OLD_SCHEMA.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | try |
| | | { |
| | | schemaBackupInstanceDir.renameTo(schemaInstanceDir); |
| | | Message message = |
| | | NOTE_SCHEMA_RESTORE_RESTORED_OLD_SCHEMA.get( |
| | | schemaInstanceDirPath); |
| | | logError(message); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_CANNOT_RESTORE_OLD_SCHEMA.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | Message message = ERR_SCHEMA_RESTORE_CANNOT_CREATE_SCHEMA_DIRECTORY.get( |
| | | backupID, schemaDirPath, stackTraceToSingleLineString(e)); |
| | | backupID, schemaInstallDirPath,schemaInstanceDirPath, |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | |
| | | catch (Exception e) |
| | | { |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | |
| | |
| | | mac.update(getBytes(fileName)); |
| | | } |
| | | |
| | | String baseDirPath ; |
| | | if (fileName.endsWith(".install")) |
| | | { |
| | | fileName = fileName.substring(fileName.lastIndexOf(".install")); |
| | | baseDirPath = schemaInstallDirPath; |
| | | } |
| | | else |
| | | { |
| | | fileName = fileName.substring(fileName.lastIndexOf(".instance")); |
| | | baseDirPath = schemaInstanceDirPath; |
| | | } |
| | | |
| | | |
| | | // If we're doing the restore, then create the output stream to write the |
| | | // file. |
| | | OutputStream outputStream = null; |
| | | if (! verifyOnly) |
| | | { |
| | | String filePath = schemaDirPath + File.separator + fileName; |
| | | String filePath = baseDirPath + File.separator + fileName; |
| | | try |
| | | { |
| | | outputStream = new FileOutputStream(filePath); |
| | |
| | | catch (Exception e) |
| | | { |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | |
| | |
| | | catch (Exception e) |
| | | { |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // Tell the user where the previous schema was archived. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupDir.getPath()); |
| | | schemaBackupInstallDir.getPath()); |
| | | logError(message); |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | Message message = ERR_SCHEMA_RESTORE_OLD_SCHEMA_SAVED.get( |
| | | schemaBackupInstanceDir.getPath()); |
| | | logError(message); |
| | | } |
| | | |
| | |
| | | // If we've gotten here, then the archive was restored successfully. Get |
| | | // rid of the temporary copy we made of the previous schema directory and |
| | | // exit. |
| | | if (schemaBackupDir != null) |
| | | if (schemaBackupInstallDir != null) |
| | | { |
| | | recursiveDelete(schemaBackupDir); |
| | | recursiveDelete(schemaBackupInstallDir); |
| | | } |
| | | if (schemaBackupInstanceDir != null) |
| | | { |
| | | recursiveDelete(schemaBackupInstanceDir); |
| | | } |
| | | |
| | | Message message = NOTE_SCHEMA_RESTORE_SUCCESSFUL.get(backupID, backupPath); |
| | |
| | | /** |
| | | * Retrieves the path to the directory containing the server schema files. |
| | | * |
| | | * @param userSchema indicates if we need to retrieve user schema or |
| | | * "unmodified" schema. |
| | | * |
| | | * @return The path to the directory containing the server schema files. |
| | | */ |
| | | public static String getSchemaDirectoryPath() |
| | | public static String getSchemaDirectoryPath(boolean userSchema) |
| | | { |
| | | File schemaDir = |
| | | DirectoryServer.getEnvironmentConfig().getSchemaDirectory(); |
| | | DirectoryServer.getEnvironmentConfig(). |
| | | getSchemaDirectory(userSchema); |
| | | if (schemaDir != null) { |
| | | return schemaDir.getAbsolutePath(); |
| | | } else { |
| | |
| | | // Construct the path to the directory that should contain the schema files |
| | | // and make sure that it exists and is a directory. Get a list of the files |
| | | // in that directory sorted in alphabetic order. |
| | | String schemaDirPath = getSchemaDirectoryPath(); |
| | | File schemaDir = new File(schemaDirPath); |
| | | String schemaInstallDirPath = getSchemaDirectoryPath(false); |
| | | String schemaInstanceDirPath = getSchemaDirectoryPath(true); |
| | | File schemaInstallDir = new File(schemaInstallDirPath); |
| | | File schemaInstanceDir = null; |
| | | |
| | | try |
| | | { |
| | | if (schemaInstanceDirPath != null) |
| | | { |
| | | schemaInstanceDir = new File(schemaInstanceDirPath); |
| | | if (schemaInstallDir.getCanonicalPath().equals( |
| | | schemaInstanceDir.getCanonicalPath())) |
| | | { |
| | | schemaInstanceDir = null; |
| | | } |
| | | } |
| | | } catch (Exception e) |
| | | { |
| | | schemaInstanceDir = null; |
| | | } |
| | | long oldestModificationTime = -1L; |
| | | long youngestModificationTime = -1L; |
| | | String[] fileNames; |
| | | |
| | | try |
| | | { |
| | | if (schemaDirPath == null || ! schemaDir.exists()) |
| | | { |
| | | Message message = ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaDirPath); |
| | | throw new InitializationException(message); |
| | | } |
| | | else if (! schemaDir.isDirectory()) |
| | | if (schemaInstallDir == null || ! schemaInstallDir.exists()) |
| | | { |
| | | Message message = |
| | | ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaDirPath); |
| | | ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaInstallDirPath); |
| | | throw new InitializationException(message); |
| | | } |
| | | if (! schemaInstallDir.isDirectory()) |
| | | { |
| | | Message message = |
| | | ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaInstallDirPath); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | File[] schemaDirFiles = schemaDir.listFiles(); |
| | | ArrayList<String> fileList = new ArrayList<String>(schemaDirFiles.length); |
| | | for (File f : schemaDirFiles) |
| | | if ((schemaInstanceDir == null) || (!schemaInstanceDir.exists()) |
| | | || (! schemaInstanceDir.isDirectory())) |
| | | { |
| | | schemaInstanceDir = null; |
| | | } |
| | | |
| | | File[] schemaInstallDirFiles = schemaInstallDir.listFiles() ; |
| | | int fileNumber = schemaInstallDirFiles.length; |
| | | File[] schemaInstanceDirFiles = null ; |
| | | if (schemaInstanceDir != null) |
| | | { |
| | | schemaInstanceDirFiles = schemaInstanceDir.listFiles(); |
| | | fileNumber =+ schemaInstanceDirFiles.length ; |
| | | } |
| | | |
| | | ArrayList<String> fileList = new ArrayList<String>(fileNumber); |
| | | for (File f : schemaInstallDirFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | |
| | | youngestModificationTime = modificationTime; |
| | | } |
| | | } |
| | | if (schemaInstanceDirFiles != null) |
| | | { |
| | | for (File f : schemaInstanceDirFiles) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | fileList.add(f.getName()); |
| | | } |
| | | |
| | | long modificationTime = f.lastModified(); |
| | | if ((oldestModificationTime <= 0L) |
| | | || (modificationTime < oldestModificationTime)) |
| | | { |
| | | oldestModificationTime = modificationTime; |
| | | } |
| | | |
| | | if ((youngestModificationTime <= 0) |
| | | || (modificationTime > youngestModificationTime)) |
| | | { |
| | | youngestModificationTime = modificationTime; |
| | | } |
| | | } |
| | | } |
| | | |
| | | fileNames = new String[fileList.size()]; |
| | | fileList.toArray(fileNames); |
| | |
| | | } |
| | | |
| | | Message message = ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES.get( |
| | | schemaDirPath, getExceptionMessage(e)); |
| | | schemaInstallDirPath, schemaInstanceDirPath, getExceptionMessage(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | |
| | |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Create an LDIF reader to use when reading the files. |
| | | String schemaDirPath = getSchemaDirectoryPath(); |
| | | String schemaDirPath = null; |
| | | |
| | | schemaDirPath = getSchemaDirectoryPath(true); |
| | | File f = new File(schemaDirPath, schemaFile); |
| | | if (!f.exists()) |
| | | { |
| | | schemaDirPath = getSchemaDirectoryPath(false); |
| | | f = new File(schemaDirPath, schemaFile); |
| | | } |
| | | LDIFReader reader; |
| | | try |
| | | { |
| | | File f = new File(schemaDirPath, schemaFile); |
| | | reader = new LDIFReader(new LDIFImportConfig(f.getAbsolutePath())); |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | // Get the name(s) of the schema files to add and make sure they exist in |
| | | // the schema directory. |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaInstallDirectory = |
| | | SchemaConfigManager.getSchemaDirectoryPath(false); |
| | | String schemaInstanceDirectory = |
| | | SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | filesToAdd = new TreeSet<String>(); |
| | | for (Attribute a : attrList) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | File schemaFile = new File(schemaDirectory, filename); |
| | | File schemaFile = new File(schemaInstallDirectory, filename); |
| | | if ((! schemaFile.exists()) || |
| | | (! schemaFile.getParent().equals(schemaDirectory))) |
| | | (! schemaFile.getParent().equals(schemaInstallDirectory))) |
| | | { |
| | | // try in the instance |
| | | schemaFile = new File(schemaInstanceDirectory, filename); |
| | | if (! schemaFile.exists()) |
| | | { |
| | | Message message = ERR_TASK_ADDSCHEMAFILE_NO_SUCH_FILE.get( |
| | | filename, schemaDirectory); |
| | | filename, schemaInstallDirectory, schemaInstanceDirectory); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | } |
| | | |
| | | Message message = ERR_TASK_ADDSCHEMAFILE_ERROR_CHECKING_FOR_FILE.get( |
| | | filename, schemaDirectory, getExceptionMessage(e)); |
| | | filename, schemaInstallDirectory, schemaInstanceDirectory, |
| | | getExceptionMessage(e)); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message, e); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.util.Enumeration; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | |
| | | */ |
| | | public static File getInstanceRootFromServerRoot(File serverRoot) |
| | | { |
| | | String instancePathFileName = serverRoot.getAbsolutePath() + |
| | | File.separator + "instance.loc"; |
| | | |
| | | // look for <installPath>/instance.loc |
| | | File f = new File(instancePathFileName); |
| | | |
| | | if (! f.exists()) |
| | | { |
| | | return serverRoot; |
| | | } |
| | | |
| | | BufferedReader reader; |
| | | try |
| | | { |
| | | reader = new BufferedReader( |
| | | new FileReader(instancePathFileName)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // Read the first line and close the file. |
| | | String line; |
| | | try |
| | | { |
| | | line = reader.readLine(); |
| | | File instanceLoc = new File(line); |
| | | if (instanceLoc.isAbsolute()) |
| | | { |
| | | return instanceLoc; |
| | | } |
| | | else |
| | | { |
| | | return new File(serverRoot.getAbsolutePath() + File.separator |
| | | + instanceLoc.getPath()); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return null; |
| | | } |
| | | finally |
| | | { |
| | | try |
| | | { |
| | | reader.close(); |
| | | } catch (Exception e) {} |
| | | } |
| | | return new File(Utils.getInstancePathFromClasspath( |
| | | serverRoot.getAbsolutePath())); |
| | | } |
| | | |
| | | |
| | |
| | | * directory of "config/schema" exists below the server root, then |
| | | * that will be returned. |
| | | * |
| | | * @param userSchema indicates if we need to retrieve user schema or |
| | | * "unmodified" schema. |
| | | * |
| | | * @return The directory that contains the server schema |
| | | * configuration files, or {@code null} if none is defined. |
| | | */ |
| | | public File getSchemaDirectory() |
| | | public File getSchemaDirectory(boolean userSchema) |
| | | { |
| | | String schemaDirectoryPath = |
| | | getProperty(PROPERTY_SCHEMA_DIRECTORY); |
| | |
| | | File serverRoot = getServerRoot(); |
| | | if (serverRoot != null) |
| | | { |
| | | File instanceRoot = getInstanceRootFromServerRoot(serverRoot); |
| | | File schemaDir = new File(instanceRoot.getAbsolutePath() + |
| | | File.separator + PATH_SCHEMA_DIR); |
| | | String schemaPath = null ; |
| | | if (userSchema) |
| | | { |
| | | File instanceRoot = |
| | | getInstanceRootFromServerRoot(serverRoot); |
| | | schemaPath = instanceRoot.getAbsolutePath(); |
| | | } |
| | | else |
| | | { |
| | | schemaPath = serverRoot.getAbsolutePath(); |
| | | } |
| | | File schemaDir = new File(schemaPath |
| | | + File.separator + PATH_SCHEMA_DIR); |
| | | if (schemaDir.exists() && schemaDir.isDirectory()) |
| | | { |
| | | return schemaDir; |
| | |
| | | { |
| | | // Get a sorted list of the files in the schema directory. |
| | | String schemaDirectory = |
| | | SchemaConfigManager.getSchemaDirectoryPath(); |
| | | TreeSet<String> schemaFileNames = new TreeSet<String>(); |
| | | SchemaConfigManager.getSchemaDirectoryPath(false); |
| | | TreeSet<File> schemaFiles = new TreeSet<File>(); |
| | | for (File f : new File(schemaDirectory).listFiles()) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | schemaFileNames.add(f.getName()); |
| | | schemaFiles.add(f); |
| | | } |
| | | } |
| | | |
| | | schemaDirectory = |
| | | SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | for (File f : new File(schemaDirectory).listFiles()) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | schemaFiles.add(f); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Open each of the files in order and read the elements that they |
| | | // contain, appending them to the appropriate lists. |
| | | for (String name : schemaFileNames) |
| | | for (File f : schemaFiles) |
| | | { |
| | | // Read the contents of the file into a list with one schema |
| | | // element per list element. |
| | | LinkedList<StringBuilder> lines = |
| | | new LinkedList<StringBuilder>(); |
| | | BufferedReader reader = |
| | | new BufferedReader(new FileReader( |
| | | new File(schemaDirectory, name))); |
| | | new BufferedReader(new FileReader(f)); |
| | | |
| | | while (true) |
| | | { |
| | |
| | | if (line.endsWith(" )")) |
| | | { |
| | | line = line.substring(0, line.length()-1) + |
| | | SCHEMA_PROPERTY_FILENAME + " '" + name + "' )"; |
| | | SCHEMA_PROPERTY_FILENAME + " '" + f.getName() + "' )"; |
| | | } |
| | | else if (line.endsWith(")")) |
| | | { |
| | | line = line.substring(0, line.length()-1) + " " + |
| | | SCHEMA_PROPERTY_FILENAME + " '" + name + "' )"; |
| | | SCHEMA_PROPERTY_FILENAME + " '" + f.getName() + "' )"; |
| | | } |
| | | else |
| | | { |
| New file |
| | |
| | | OpenDS Directory Server |
| | | |
| | | This archive contains the OpenDS Directory Server. Complete documentation for |
| | | this product may be found online at https://OpenDS.dev.java.net/. |
| | | |
| | | To configure the server, run the configure script. |
| | | |
| | | This product is made available under the Common Development and Distribution |
| | | License (CDDL). The complete text for this license, and for alternate licenses |
| | | of included components, may be found in the legal-notices directory. |
| | | |
| New file |
| | |
| | | Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
| | | Use is subject to license terms. |
| | | |
| | | The contents of this file are subject to the terms of the |
| | | Common Development and Distribution License (the "License"). |
| | | You may not use this file except in compliance with the License. |
| | | |
| | | You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
| | | or http://www.opensolaris.org/os/licensing. |
| | | See the License for the specific language governing permissions |
| | | and limitations under the License. |
| | | |
| | | When distributing Covered Code, include this CDDL HEADER in each |
| | | file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
| | | If applicable, add the following below this CDDL HEADER, with the |
| | | fields enclosed by brackets "[]" replaced with your own identifying |
| | | information: Portions Copyright [yyyy] [name of copyright owner] |
| New file |
| | |
| | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| | | <html> |
| | | <head> |
| | | <title>How To Install Open DS</title> |
| | | <style type="text/css"> |
| | | <!-- |
| | | body { font-family: Arial, Helvetica, sans-serif; |
| | | font-size: 12px; |
| | | color: #333; background-color: #fff; } |
| | | h1 { font-size: 2.0em; font-weight: normal; |
| | | margin-top: 0em; margin-bottom: 0em; } |
| | | h2 { font-size: 1.7em; font-weight: normal; |
| | | margin: 1.2em 0em .8em 0em; |
| | | border-bottom: 1px #D9D9D9 solid; } |
| | | h3 { font-size: 1.4em; font-weight: bold; |
| | | margin: 1.2em 0em .8em 0em; } |
| | | |
| | | a:link {color:#069;text-decoration:none;} |
| | | a:visited {color:#069;text-decoration:none;} |
| | | a:active, a:hover {color:#069;text-decoration:underline;} |
| | | |
| | | --> |
| | | </style> |
| | | </head> |
| | | |
| | | <body> |
| | | |
| | | <img src="images/opends_logo.png" alt="OpenDS logo" border="0" align=right> |
| | | |
| | | <br> |
| | | |
| | | <h2>How To Configure OpenDS</h2> |
| | | <p>If you are reading this page, you have already installed the OpenDS package. |
| | | |
| | | <h3>Before You Configure</h3> |
| | | A Java SE 5.0 (version 1.5.0_08) or higher runtime environment must be installed. |
| | | It is recommended that your system have at least 100MB of disk space and |
| | | 256MB of free memory to run OpenDS for evaluation purposes. Note that |
| | | you can configure OpenDS in such a way that it requires substantially |
| | | less, or more, disk space. For more information, see the |
| | | <a href="https://www.opends.org/wiki/page/OpenDSSystemRequirements">OpenDS System Requirements</a>. |
| | | |
| | | <h3>To Configure OpenDS</h3> |
| | | <ol> |
| | | <li>As root, type the following command: |
| | | <br> |
| | | <span style="font-family: monospace; white-space: pre;"> |
| | | $BASEDIR/opends/configure --instancePath {instancePath} [ --userName {userName} [ --groupName {groupName} ] ] |
| | | </span> |
| | | </li> |
| | | <li>As {userName}, type the following command: |
| | | <br> |
| | | <span style="font-family: monospace; white-space: pre;"> |
| | | $BASEDIR/opends/setup |
| | | </span> |
| | | </li> |
| | | </ol> |
| | | |
| | | <h3>See Also</h3> |
| | | <ul> |
| | | <li><a href="https://www.opends.org/wiki/page/InstallingTheOpenDSDirectoryServer">Installing the OpenDS Directory Server</a> |
| | | <br> |
| | | </li> |
| | | <li> <a href="https://www.opends.org/wiki/page/Setup">setup</a> |
| | | </li> |
| | | </ul> |
| | | </body> |
| | | </html> |
| New file |
| | |
| | | How To Install OpenDS |
| | | ===================== |
| | | |
| | | If you are reading this page, you have already installed the OpenDS package. |
| | | |
| | | Before You Configure |
| | | ------------------ |
| | | A Java SE 5.0 (version 1.5.0_08) or higher runtime environment must be installed. It is |
| | | recommended that your system have at least 100MB of disk space and 256MB of free memory to run |
| | | OpenDS for evaluation purposes. Note that you can configure OpenDS in such a way that it requires |
| | | substantially less, or more, disk space. For more information, see the OpenDS System Requirements |
| | | at https://www.opends.org/wiki/page/OpenDSSystemRequirements. |
| | | |
| | | To Configure OpenDS |
| | | -------------------------------------- |
| | | 1. As root, type the following command: |
| | | $BASEDIR/opends/configure --instancePath {instancePath} [ --userName {userName} [ --groupName {groupName} ] ] |
| | | 2. As {userName}, type the following command: |
| | | $BASEDIR/opends/setup |
| | | |
| | | See Also |
| | | -------- |
| | | * Installing the OpenDS Directory Server |
| | | (https://www.opends.org/wiki/page/InstallingTheOpenDSDirectoryServer) |
| | | * setup (https://www.opends.org/wiki/page/Setup) |
| New file |
| | |
| | | <!-- |
| | | ! CDDL HEADER START |
| | | ! |
| | | ! The contents of this file are subject to the terms of the |
| | | ! Common Development and Distribution License, Version 1.0 only |
| | | ! (the "License"). You may not use this file except in compliance |
| | | ! with the License. |
| | | ! |
| | | ! You can obtain a copy of the license at |
| | | ! trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | ! or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | ! See the License for the specific language governing permissions |
| | | ! and limitations under the License. |
| | | ! |
| | | ! When distributing Covered Code, include this CDDL HEADER in each |
| | | ! file and include the License file at |
| | | ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | ! add the following below this CDDL HEADER, with the fields enclosed |
| | | ! by brackets "[]" replaced with your own identifying information: |
| | | ! Portions Copyright [yyyy] [name of copyright owner] |
| | | ! |
| | | ! CDDL HEADER END |
| | | ! |
| | | ! |
| | | ! Copyright 2006-2008 Sun Microsystems, Inc. |
| | | ! --> |
| | | |
| | | <project name="OpenDS SVR4 layout" basedir="."> |
| | | <description> |
| | | This is a build script that extends the OpenDS build script by adding |
| | | SVR4 packaging functions. |
| | | </description> |
| | | |
| | | |
| | | <target name="pkgversion" |
| | | description="Set pkg.version property" > |
| | | <!-- Construct the version number string --> |
| | | <taskdef name="getversionnumber" |
| | | classname="org.opends.build.tools.CreateVersionString"> |
| | | <classpath> |
| | | <fileset dir="${build.dir}/build-tools"> |
| | | <include name="*.jar" /> |
| | | </fileset> |
| | | </classpath> |
| | | </taskdef> |
| | | |
| | | <getversionnumber property="pkg.version" /> |
| | | </target> |
| | | |
| | | <property name="resource.dir" location="src/resource" /> |
| | | |
| | | <!-- Construct layout --> |
| | | <target name="layout" if="isSunOS" |
| | | description="Create layout based on zip layout" > |
| | | <!-- Get the revision number of the current Subversion workspace --> |
| | | <taskdef name="getsvnrevision" |
| | | classname="org.opends.build.tools.GetSubversionRevision"> |
| | | <classpath> |
| | | <fileset dir="${build.dir}/build-tools"> |
| | | <include name="*.jar" /> |
| | | </fileset> |
| | | <fileset dir="${svnkit.dir}"> |
| | | <include name="*.jar" /> |
| | | </fileset> |
| | | </classpath> |
| | | </taskdef> |
| | | |
| | | <!-- <getsvnrevision property="REVISION_NUMBER" /> |
| | | <tstamp> |
| | | <format property="REVISION_NUMBER" pattern="MMddhhmm"/> |
| | | </tstamp> |
| | | --> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <property name="zip.dir" location="${pkg.dir}/${product}-${pkg.version}" /> |
| | | <echo message="Building layout for ${pkg.name} pkg based on ${zip.dir}" /> |
| | | <!-- copy ZIP layout. Use exec instead of copy task to preserve file permissions --> |
| | | <mkdir dir="${svr4.layout.dir}"/> |
| | | <exec executable="cp"> |
| | | <arg value="-R"/> |
| | | <arg value="${zip.dir}"/> |
| | | <arg value="${svr4.layout.pkg.dir}"/> |
| | | </exec> |
| | | <!-- Remove Windows specific files --> |
| | | <delete includeemptydirs="true"> |
| | | <fileset dir="${svr4.layout.pkg.dir}" includes="**/*.exe"/> |
| | | <fileset dir="${svr4.layout.pkg.dir}" includes="**/*.bat"/> |
| | | <fileset dir="${svr4.layout.pkg.dir}" includes="**/bat/"/> |
| | | <fileset dir="${svr4.layout.pkg.dir}" includes="**/README_WINDOWS.txt"/> |
| | | </delete> |
| | | <!-- Remove MacOS specific files --> |
| | | <delete includeemptydirs="true"> |
| | | <fileset dir="${svr4.layout.pkg.dir}" includes="**/*.app/" /> |
| | | </delete> |
| | | <!-- Remove instance.loc file --> |
| | | <delete file="${svr4.layout.pkg.dir}/instance.loc" /> |
| | | <!-- Remove uninstall file --> |
| | | <delete file="${svr4.layout.pkg.dir}/uninstall" /> |
| | | <!-- Remove ldaptools --> |
| | | <delete file="${svr4.layout.pkg.dir}/bin/ldapcompare" /> |
| | | <delete file="${svr4.layout.pkg.dir}/bin/ldapdelete" /> |
| | | <delete file="${svr4.layout.pkg.dir}/bin/ldapmodify" /> |
| | | <delete file="${svr4.layout.pkg.dir}/bin/ldapsearch" /> |
| | | <!-- Remove ZIP README / install files --> |
| | | <delete file="${svr4.layout.pkg.dir}/README" /> |
| | | <delete file="${svr4.layout.pkg.dir}/install.txt" /> |
| | | <delete file="${svr4.layout.pkg.dir}/install.html" /> |
| | | <!-- Add SVR4 README / install files --> |
| | | <copy file="${svr4.src.dir}/README" tofile="${svr4.layout.pkg.dir}/README" /> |
| | | <copy file="${svr4.src.dir}/install.txt" tofile="${svr4.layout.pkg.dir}/install.txt" /> |
| | | <copy file="${svr4.src.dir}/install.html" tofile="${svr4.layout.pkg.dir}/install.html" /> |
| | | <!-- Add configure script --> |
| | | <copy file="${resource.dir}/configure" tofile="${svr4.layout.pkg.dir}/configure" /> |
| | | <chmod file="${svr4.layout.pkg.dir}/configure" perm="744" /> |
| | | <!-- Replace zip upgrade script by svr4 upgrade script --> |
| | | <delete file="${svr4.layout.pkg.dir}/upgrade" /> |
| | | <copy file="${resource.dir}/upgrade_svr4" tofile="${svr4.layout.pkg.dir}/upgrade" /> |
| | | <chmod file="${svr4.layout.pkg.dir}/upgrade" perm="755" /> |
| | | <!-- Move instance files in ${svr4.layout.pkg.dir}/tmpl_instance --> |
| | | <mkdir dir="${svr4.layout.pkg.dir}/tmpl_instance"/> |
| | | <chmod dir="${svr4.layout.pkg.dir}/tmpl_instance" perm="755"/> |
| | | <mkdir dir="${svr4.layout.pkg.dir}/tmpl_instance/lib"/> |
| | | <chmod dir="${svr4.layout.pkg.dir}/tmpl_instance/lib" perm="755"/> |
| | | <mkdir dir="${svr4.layout.pkg.dir}/tmpl_instance/lib/extensions"/> |
| | | <chmod dir="${svr4.layout.pkg.dir}/tmpl_instance/lib/extensions" perm="755"/> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/bak"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/bak"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/changelogDb"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/changelogDb"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/classes"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/classes"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/config"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/config"/> |
| | | </move> |
| | | <mkdir dir="${svr4.layout.pkg.dir}/config"/> |
| | | <chmod dir="${svr4.layout.pkg.dir}/config" perm="755"/> |
| | | <move todir="${svr4.layout.pkg.dir}/config/schema"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/tmpl_instance/config/schema"/> |
| | | </move> |
| | | <mkdir dir="${svr4.layout.pkg.dir}/tmpl_instance/config/schema"/> |
| | | <chmod dir="${svr4.layout.pkg.dir}/tmpl_instance/config/schema" perm="755"/> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/db"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/db"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/import-tmp"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/import-tmp"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/ldif"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/ldif"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/locks"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/locks"/> |
| | | </move> |
| | | <move todir="${svr4.layout.pkg.dir}/tmpl_instance/logs"> |
| | | <fileset dir="${svr4.layout.pkg.dir}/logs"/> |
| | | </move> |
| | | <!-- Create buildinfo file --> |
| | | <echo message="${pkg.version}.${REVISION_NUMBER}" file="${svr4.layout.pkg.dir}/tmpl_instance/config/buildinfo" /> |
| | | </target> |
| | | |
| | | </project> |
| New file |
| | |
| | | # Info for prototype |
| | | pkg.name=opends |
| | | pkg.fullname=OpenDS, an open source LDAP directory server |
| | | pkg.desc=OpenDS, an open source LDAP directory server |
| | | pkg.arch=all |
| | | pkg.vendor=opends.org |
| | | pkg.basedir=/opt |
| | |
| | | testInstanceRoot.mkdirs(); |
| | | } |
| | | |
| | | File testInstanceSchema = |
| | | new File (testInstanceRoot, "config" + File.separator + "schema"); |
| | | testInstanceSchema.mkdirs(); |
| | | |
| | | //db_verify is second jeb backend used by the jeb verify test cases |
| | | //db_rebuild is the third jeb backend used by the jeb rebuild test cases |
| | | //db_unindexed is the forth backend used by the unindexed search privilege |
| | | //test cases |
| | | String[] installSubDirectories = { "bin", "lib", "bat"}; |
| | | String[] installSubDirectories = { "bin", "lib", "bat", "config"}; |
| | | String[] instanceSubDirectories = { "bak", "changelogDb", "classes", |
| | | "config", "db", "import-tmp", "db_verify", |
| | | "ldif", "locks", "logs", "db_rebuild", |
| | |
| | | File testResourceDir = new File(testSrcRoot, "resource"); |
| | | // Set the class variable |
| | | testConfigDir = new File(testInstanceRoot, "config"); |
| | | File testSchemaDir = new File(testInstallRoot, "config"); |
| | | File testClassesDir = new File(testInstanceRoot, "classes"); |
| | | File testLibDir = new File(testInstallRoot, "lib"); |
| | | File testBinDir = new File(testInstallRoot, "bin"); |
| | |
| | | copyDirectory(new File(resourceDir, "bin"), testBinDir); |
| | | copyDirectory(new File(resourceDir, "config"), testConfigDir); |
| | | copyDirectory(new File(resourceDir, "schema"), |
| | | new File(testConfigDir, "schema")); |
| | | new File(testSchemaDir, "schema")); |
| | | copyDirectory(new File(resourceDir, "MakeLDIF"), |
| | | new File(testConfigDir, "MakeLDIF")); |
| | | copyDirectory(new File(snmpResourceDir, "security"), |
| | |
| | | String attrName = "testaddattributetypetoaltschemafile"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-attrtype.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | String attrName = "testreplaceattributetypeinaltschemafile"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-replaceattrtype.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | String ocName = "testaddobjectclasstoaltschemafile"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-oc.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | String nameFormName = "testaddnameformtoaltschemafile"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-nameform.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | String ocName = "testadddcrtoaltschemafileoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-dcr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | int ruleID = 999010; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-dsr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(true), |
| | | "98-schema-test-mru.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | |
| | | hasPrivilege); |
| | | |
| | | |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | String identifier; |
| | | Entry authNEntry = conn.getAuthenticationInfo().getAuthenticationEntry(); |
| | |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | String[] fileLines = |
| | | { |
| | |
| | | Thread.sleep(2); |
| | | |
| | | |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | |
| | | SchemaTestMatchingRule matchingRule1 = |
| | |
| | | Thread.sleep(2); |
| | | |
| | | |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | File emptyFile = new File(schemaDirectory, "05-empty.ldif"); |
| | | emptyFile.createNewFile(); |
| | |
| | | public void testAddInvalidSchemaFile() |
| | | throws Exception |
| | | { |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | File invalidFile = new File(schemaDirectory, "05-invalid.ldif"); |
| | | BufferedWriter writer = new BufferedWriter(new FileWriter(invalidFile)); |
| | |
| | | hasPrivilege); |
| | | |
| | | |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(); |
| | | String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath(true); |
| | | |
| | | String identifier; |
| | | Entry authNEntry = conn.getAuthenticationInfo().getAuthenticationEntry(); |