6331N/A#!/bin/ksh93
6110N/A#
6110N/A# CDDL HEADER START
6110N/A#
6110N/A# The contents of this file are subject to the terms of the
6110N/A# Common Development and Distribution License, Version 1.0 only
6110N/A# (the "License"). You may not use this file except in compliance
6110N/A# with the License.
6110N/A#
6110N/A# You can obtain a copy of the license at
6110N/A# trunk/opends/resource/legal-notices/CDDLv1_0.txt
6110N/A# or http://forgerock.org/license/CDDLv1.0.html.
6110N/A# See the License for the specific language governing permissions
6110N/A# and limitations under the License.
6110N/A#
6110N/A# When distributing Covered Code, include this CDDL HEADER in each
6110N/A# file and include the License file at
6110N/A# trunk/opends/resource/legal-notices/CDDLv1_0.txt. If applicable,
6110N/A# add the following below this CDDL HEADER, with the fields enclosed
6110N/A# by brackets "[]" replaced with your own identifying information:
6110N/A# Portions Copyright [yyyy] [name of copyright owner]
6110N/A#
6110N/A# CDDL HEADER END
6110N/A#
6110N/A# Portions Copyright 2006-2010 Sun Microsystems Inc.
6110N/A# Copyright 2010-2013 ForgeRock AS
575N/A
575N/A# Determine the location to this script so that we know where we are in the
5612N/A# OpenDJ source tree.
6331N/ASCRIPT_DIR=${.sh.file%/*/*}
6331N/AROOT_DIR=${SCRIPT_DIR%/*}
575N/Acd "${SCRIPT_DIR}"
6331N/Aprint "ROOT_DIR: ${ROOT_DIR}"
575N/A
6331N/A[[ -z ${PRODUCT_FILE} ]] && PRODUCT_FILE="${ROOT_DIR}/PRODUCT"
6331N/Aprint "PRODUCT_FILE: ${PRODUCT_FILE}"
5250N/A
6331N/Aif [[ -z ${PRODUCT_NAME} ]]; then
6331N/A PRODUCT_NAME=${ grep SHORT_NAME= "${PRODUCT_FILE}" ; }
6331N/A PRODUCT_NAME=${PRODUCT_NAME#*=}
5250N/Afi
6331N/Aprint "PRODUCT_NAME: ${PRODUCT_NAME}"
575N/A
575N/A# Make sure that a few constants are defined that will be needed to build the
575N/A# web start archive.
6331N/A[[ -z ${PROTOCOL} ]] && PROTOCOL='http'
6331N/Aprint "PROTOCOL: ${PROTOCOL}"
575N/A
6331N/A[[ -z ${ADDRESS} ]] && ADDRESS='www.forgerock.org'
6331N/Aprint "ADDRESS: ${ADDRESS}"
6331N/Aprint "PORT: ${PORT}"
575N/A
6331N/A[[ -z ${BASE_PATH} ]] && BASE_PATH='/downloads/opendj/latest/install'
6331N/Aprint "BASE_PATH: ${BASE_PATH}"
6331N/A
6331N/A[[ -z ${INSTALL_JNLP_FILENAME} ]] && INSTALL_JNLP_FILENAME='QuickSetup.jnlp'
6331N/Aprint "INSTALL_JNLP_FILENAME: ${INSTALL_JNLP_FILENAME}"
575N/A
6331N/A[[ -z ${PORT} ]] && INSTALLER_URI="${PROTOCOL}://${ADDRESS}${BASE_PATH}" || \
6331N/A INSTALLER_URI="${PROTOCOL}://${ADDRESS}:${PORT}${BASE_PATH}"
1158N/A
6331N/AVENDOR='http://www.forgerock.com/'
6331N/AHOMEPAGE='http://www.forgerock.com/opendj.html'
575N/A
575N/A# See if we can find the location of the dependencies in the Java environment.
575N/A# If not, then fail.
6331N/Aif [[ -z ${JAVA_HOME} ]]; then
6331N/A JAVA_HOME=${ java -cp "${ROOT_DIR}/resource" FindJavaHome 2> /dev/null ; }
6331N/A if [[ -z ${JAVA_HOME} ]]; then
6331N/A print -u2 'Please set JAVA_HOME to the root of a Java 6.0 installation.'
6331N/A exit 1
6331N/A fi
575N/Afi
575N/A
575N/AJAR="${JAVA_HOME}/bin/jar"
6331N/Aif [[ ! -x ${JAR} ]]; then
6331N/A print -u2 '
6331N/AERROR: Cannot find the jar utility.
6331N/A Is JAVA_HOME ('"${JAVA_HOME}"'set correctly?"
6331N/A It should point to the root of a JDK (not a JRE) installation
6331N/A'
6331N/A exit 1
575N/Afi
575N/A
575N/AJARSIGNER="${JAVA_HOME}/bin/jarsigner"
6331N/Aif [[ ! -x ${JARSIGNER} ]]; then
6331N/A print -u2 '
6331N/AERROR: Cannot find the jarsigner utility.
6331N/A Is JAVA_HOME ('"${JAVA_HOME}"') set correctly?"
6331N/A It should point to the root of a JDK (not a JRE) installation
6331N/A'
6331N/A exit 1
575N/Afi
575N/A
5612N/A# Make sure that the OpenDJ build directory exists. If not, then create it.
6331N/A[[ -z ${BUILD_DIR} ]] && BUILD_DIR="${ROOT_DIR}/build"
6331N/Aprint "BUILD_DIR: ${BUILD_DIR}"
5157N/A
6331N/Aif [[ ! -d ${BUILD_DIR} ]]; then
6331N/A print -u2 "WARNING: ${BUILD_DIR} does not exist. Building the server ..."
6331N/A cd ${ROOT_DIR} && ant
6331N/A if (( $? != 0 )); then
6331N/A print -u2 'ERROR: Build failed. Aborting creation of web start archive.'
6331N/A exit 2
6331N/A fi
6331N/A print "The server was built successfully."
575N/Afi
575N/A
575N/A
5612N/A# Determine what the name should be for the OpenDJ zip file name, but without
575N/A# the ".zip" extension.
6331N/AZIP_FILENAME_BASE="${BUILD_DIR}/package/generic"
575N/A
575N/A
575N/A# Create the directory structure into which we will place the archive.
6331N/Aprint "Creating the initial directory structure ..."
575N/AWEBSTART_DIR="${BUILD_DIR}/webstart"
575N/AINSTALL_DIR="${WEBSTART_DIR}/install"
575N/Arm -rf "${INSTALL_DIR}"
575N/Amkdir -p "${INSTALL_DIR}/lib"
575N/A
575N/A
575N/A# Copy the static files from the script directory into the appropriate places
575N/A# in the archive.
6331N/Aprint "Copying static content into place ..."
6331N/Acp -rp "${SCRIPT_DIR}/images" "${INSTALL_DIR}"
575N/A
5612N/A# Copy the appropriate OpenDJ library files and make sure they are signed.
6331N/APKG_LIB_DIR="${ZIP_FILENAME_BASE}/lib"
575N/ACERT_KEYSTORE="${ROOT_DIR}/tests/unit-tests-testng/resource/server.keystore"
6331N/ACERT_KEYSTORE_PIN='password'
6331N/ACERT_ALIAS='server-cert'
6331N/Afor LIBFILE in "${PRODUCT_NAME}.jar" je.jar quicksetup.jar; do
6331N/A print "Signing ${LIBFILE} ..."
6331N/A cp "${PKG_LIB_DIR}/${LIBFILE}" "${INSTALL_DIR}/lib"
6331N/A "${JARSIGNER}" -keystore "${CERT_KEYSTORE}" \
6331N/A -keypass "${CERT_KEYSTORE_PIN}" \
6331N/A -storepass "${CERT_KEYSTORE_PIN}" \
6331N/A "${INSTALL_DIR}/lib/${LIBFILE}" "${CERT_ALIAS}"
575N/Adone
575N/A
6319N/A# Create and sign the licence.jar file if exists.
6331N/Aif [[ -d ${ZIP_FILENAME_BASE}/Legal ]]; then
6331N/A print 'Creating license.jar ...'
6331N/A cp "${ZIP_FILENAME_BASE}/Legal" "${INSTALL_DIR}/lib"
6331N/A cd "${BUILD_DIR}/package"
6331N/A "${JAR}" -cf "${INSTALL_DIR}/lib/license.jar" \
6331N/A -C "${ZIP_FILENAME_BASE}/" "Legal"
6331N/A cd "${INSTALL_DIR}/lib"
6331N/A print 'Signing license.jar ...'
6331N/A "${JARSIGNER}" -keystore "${CERT_KEYSTORE}" \
6331N/A -keypass "${CERT_KEYSTORE_PIN}" \
6331N/A -storepass "${CERT_KEYSTORE_PIN}" license.jar "${CERT_ALIAS}"
6331N/A # Create the resource line to add to the jnlp script.
6331N/A LICENSEJAR='<jar href="lib/license.jar" download="eager"/>'
6319N/Afi
575N/A
575N/A# Create and sign the zipped.jar file.
6331N/Aecho 'Creating zipped.jar ...'
575N/Acd "${BUILD_DIR}/package"
575N/A"${JAR}" -cf "${INSTALL_DIR}/lib/zipped.jar" "${ZIP_FILENAME_BASE}.zip"
575N/Acd "${INSTALL_DIR}/lib"
6331N/Aprint 'Signing zipped.jar ...'
575N/A"${JARSIGNER}" -keystore "${CERT_KEYSTORE}" -keypass "${CERT_KEYSTORE_PIN}" \
6331N/A -storepass "${CERT_KEYSTORE_PIN}" zipped.jar "${CERT_ALIAS}"
575N/A
575N/A
1158N/A# Create the Setup JNLP file with the appropriate contents.
6331N/Aprint "Creating Setup JNLP file ${INSTALL_JNLP_FILENAME} ..."
575N/Acd ..
1158N/Acat > "${INSTALL_JNLP_FILENAME}" <<ENDOFINSTALLJNLP
575N/A<?xml version="1.0" encoding="utf-8"?>
5250N/A<!-- JNLP File for ${PRODUCT_NAME} QuickSetup Application -->
953N/A<jnlp spec="1.5+"
1158N/A codebase="${INSTALLER_URI}" href="${INSTALL_JNLP_FILENAME}">
575N/A <information>
5250N/A <title>${PRODUCT_NAME} QuickSetup Application</title>
5252N/A <vendor>${VENDOR}</vendor>
5252N/A <homepage href="${HOMEPAGE}"/>
5250N/A <description>${PRODUCT_NAME} QuickSetup Application</description>
5250N/A <description kind="short">${PRODUCT_NAME} Web Start Installer</description>
6311N/A <icon href="images/opendjhref.png" height="128" width="128"/>
6311N/A <icon kind="splash" href="images/opendjsplash.png" height="114" width="479"/>
575N/A </information>
575N/A
575N/A <security>
575N/A <all-permissions/>
575N/A </security>
575N/A
575N/A <resources>
5218N/A <j2se version="1.6+" java-vm-args="-client"/>
575N/A <jar href="lib/quicksetup.jar" download="eager" main="true"/>
6319N/A ${LICENSEJAR}
6182N/A <jar href="lib/${PRODUCT_NAME}.jar" download="lazy"/>
6182N/A <jar href="lib/je.jar" download="lazy"/>
575N/A <jar href="lib/zipped.jar" download="lazy"/>
575N/A <property name="org.opends.quicksetup.iswebstart" value="true" />
6265N/A <property name="org.opends.quicksetup.Application.class" value="org.opends.quicksetup.installer.webstart.WebStartInstaller"/>
6182N/A <property name="org.opends.quicksetup.lazyjarurls" value="${INSTALLER_URI}/lib/${PRODUCT_NAME}.jar ${INSTALLER_URI}/lib/zipped.jar ${INSTALLER_URI}/lib/je.jar" />
575N/A <property name="org.opends.quicksetup.zipfilename" value="${ZIP_FILENAME_BASE}.zip"/>
575N/A </resources>
5612N/A
579N/A <resources os="AIX">
5218N/A <j2se version="1.6+"/>
579N/A </resources>
5612N/A
575N/A <application-desc main-class="org.opends.quicksetup.SplashScreen"/>
575N/A</jnlp>
1158N/AENDOFINSTALLJNLP
1158N/A
575N/A
575N/A# Tell the user where the files are.
6331N/Aprint '
6331N/AThe deployable content may be found in:
6331N/A '"${BUILD_DIR}/webstart"'
6331N/AIt is intended for deployment at:
6331N/A '"${INSTALLER_URI}"'
6331N/A'