create-webstart-standalone.sh revision 3488
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington#!/bin/sh
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Determine the location to this script so that we know where we are in the
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# OpenDS source tree.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostercd "`dirname $0`"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterSCRIPT_DIR=`pwd`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostercd ../..
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterROOT_DIR=`pwd`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostercd "${SCRIPT_DIR}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Make sure that a few constants are defined that will be needed to build the
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# web start archive.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${PROTOCOL}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster PROTOCOL="http"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "PROTOCOL: ${PROTOCOL}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${ADDRESS}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ADDRESS="www.opends.org"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "ADDRESS: ${ADDRESS}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "PORT: ${PORT}"
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${BASE_PATH}"
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunningtonthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster BASE_PATH="/install"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "BASE_PATH: ${BASE_PATH}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${INSTALL_JNLP_FILENAME}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster INSTALL_JNLP_FILENAME="QuickSetup.jnlp"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "INSTALL_JNLP_FILENAME: ${INSTALL_JNLP_FILENAME}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${PORT}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster INSTALLER_URI="${PROTOCOL}://${ADDRESS}${BASE_PATH}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterelse
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster INSTALLER_URI="${PROTOCOL}://${ADDRESS}:${PORT}${BASE_PATH}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# See if we can find the location of the dependencies in the Java environment.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# If not, then fail.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test -z "${JAVA_HOME}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster JAVA_HOME=`java -cp ${ROOT_DIR}/resource FindJavaHome 2> /dev/null`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster if test -z "${JAVA_HOME}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster then
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster exit 1
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee else
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster export JAVA_HOME
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster fi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterJAR="${JAVA_HOME}/bin/jar"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test ! -x "${JAR}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo "ERROR: Cannot find the ${JAR} utility."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo " Is JAVA_HOME set correctly?"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo " It should point to the root of a JDK (not a JRE) installation"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster exit 1
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterJARSIGNER="${JAVA_HOME}/bin/jarsigner"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test ! -x "${JARSIGNER}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo "ERROR: Cannot find the ${JARSIGNER} utility."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo " Is JAVA_HOME set correctly?"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo " It should point to the root of a JDK (not a JRE) installation"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster exit 1
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Make sure that the OpenDS build directory exists. If not, then create it.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterBUILD_DIR="${ROOT_DIR}/build"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterif test ! -d "${BUILD_DIR}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterthen
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo "WARNING: ${BUILD_DIR} does not exist. Building the server ..."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster "${ROOT_DIR}/build.sh"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster EXIT_CODE=$?
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster if test "${EXIT_CODE}" -ne 0
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster then
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo "ERROR: Build failed. Aborting creation of web start archive."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster exit ${EXIT_CODE}
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster else
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster echo "The server was built successfully."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster fi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterfi
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Determine what the name should be for the OpenDS zip file name, but without
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# the ".zip" extension.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterZIP_FILEPATH=`ls ${ROOT_DIR}/build/package/OpenDS*.zip`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterZIP_FILENAME=`basename ${ZIP_FILEPATH}`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterZIP_FILENAME_BASE=`echo ${ZIP_FILENAME} | sed -e 's/\.zip//'`
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Create the directory structure into which we will place the archive.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "Creating the initial directory structure ..."
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterWEBSTART_DIR="${BUILD_DIR}/webstart"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterINSTALL_DIR="${WEBSTART_DIR}/install"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterrm -rf "${INSTALL_DIR}"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostermkdir -p "${INSTALL_DIR}/lib"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# Copy the static files from the script directory into the appropriate places
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster# in the archive.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterecho "Copying static content into place ..."
cp -Rp "${SCRIPT_DIR}/images" "${INSTALL_DIR}"
find "${INSTALL_DIR}/images" -type d -name '.svn' -exec rm -rf {} \;
# Copy the appropriate OpenDS library files and make sure they are signed.
PKG_LIB_DIR="${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/lib"
CERT_KEYSTORE="${ROOT_DIR}/tests/unit-tests-testng/resource/server.keystore"
CERT_KEYSTORE_PIN="password"
CERT_ALIAS="server-cert"
for LIBFILE in OpenDS.jar je.jar aspectjrt.jar quicksetup.jar
do
echo "Signing ${LIBFILE} ..."
cp "${PKG_LIB_DIR}/${LIBFILE}" "${INSTALL_DIR}/lib"
"${JARSIGNER}" -keystore "${CERT_KEYSTORE}" -keypass "${CERT_KEYSTORE_PIN}" \
-storepass "${CERT_KEYSTORE_PIN}" \
"${INSTALL_DIR}/lib/${LIBFILE}" "${CERT_ALIAS}"
done
# Create and sign the zipped.jar file.
echo "Creating zipped.jar ..."
cd "${BUILD_DIR}/package"
"${JAR}" -cf "${INSTALL_DIR}/lib/zipped.jar" "${ZIP_FILENAME_BASE}.zip"
cd "${INSTALL_DIR}/lib"
echo "Signing zipped.jar ..."
"${JARSIGNER}" -keystore "${CERT_KEYSTORE}" -keypass "${CERT_KEYSTORE_PIN}" \
-storepass "${CERT_KEYSTORE_PIN}" zipped.jar "${CERT_ALIAS}"
# Create the Setup JNLP file with the appropriate contents.
echo "Creating Setup JNLP file ${INSTALL_JNLP_FILENAME} ..."
cd ..
cat > "${INSTALL_JNLP_FILENAME}" <<ENDOFINSTALLJNLP
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for OpenDS QuickSetup Application -->
<jnlp spec="1.5+"
codebase="${INSTALLER_URI}" href="${INSTALL_JNLP_FILENAME}">
<information>
<title>OpenDS QuickSetup Application</title>
<vendor>http://www.opends.org/</vendor>
<homepage href="http://www.opends.org"/>
<description>OpenDS QuickSetup Application</description>
<description kind="short">OpenDS Web Start Installer</description>
<icon href="images/opendshref.png" height="128" width="128"/>
<icon kind="splash" href="images/opendssplash.png" height="114" width="479"/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+" java-vm-args="-client"/>
<jar href="lib/quicksetup.jar" download="eager" main="true"/>
<jar href="lib/OpenDS.jar" download="lazy"/>
<jar href="lib/je.jar" download="lazy"/>
<jar href="lib/aspectjrt.jar" download="lazy"/>
<jar href="lib/zipped.jar" download="lazy"/>
<property name="org.opends.quicksetup.iswebstart" value="true" />
<property name="org.opends.quicksetup.Application.class" value="org.opends.quicksetup.installandupgrader.InstallAndUpgrader"/>
<property name="org.opends.quicksetup.lazyjarurls" value="${INSTALLER_URI}/lib/OpenDS.jar ${INSTALLER_URI}/lib/zipped.jar ${INSTALLER_URI}/lib/je.jar ${INSTALLER_URI}/lib/aspectjrt.jar" />
<property name="org.opends.quicksetup.zipfilename" value="${ZIP_FILENAME_BASE}.zip"/>
</resources>
<resources os="AIX">
<j2se version="1.5+"/>
</resources>
<application-desc main-class="org.opends.quicksetup.SplashScreen"/>
</jnlp>
ENDOFINSTALLJNLP
# Tell the user where the files are.
echo "The deployable content may be found in ${ROOT_DIR}/build/webstart"
echo "It is intended for deployment at ${INSTALLER_URI}"