18861N/A<!--
18861N/A ! CDDL HEADER START
18861N/A !
18861N/A ! The contents of this file are subject to the terms of the
18861N/A ! Common Development and Distribution License, Version 1.0 only
18861N/A ! (the "License"). You may not use this file except in compliance
18861N/A ! with the License.
18861N/A !
18861N/A ! You can obtain a copy of the license at
18861N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
18861N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
18861N/A ! See the License for the specific language governing permissions
18861N/A ! and limitations under the License.
18861N/A !
18861N/A ! When distributing Covered Code, include this CDDL HEADER in each
19141N/A ! file and include the License file at
18861N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
18861N/A ! add the following below this CDDL HEADER, with the fields enclosed
18861N/A ! by brackets "[]" replaced with your own identifying information:
19142N/A ! Portions Copyright [yyyy] [name of copyright owner]
18861N/A !
18861N/A ! CDDL HEADER END
18861N/A !
18861N/A !
18861N/A ! Copyright 2008-2009 Sun Microsystems, Inc.
19142N/A ! Portions Copyright 2013 ForgeRock AS
18861N/A ! -->
18861N/A<project name="staf">
18861N/A
18861N/A <description>
18861N/A Manage STAF (install/uninstall, start/stop).
18861N/A </description>
18861N/A
18861N/A <!-- Install STAF and services -->
18861N/A <target name="install">
18861N/A <if>
18861N/A <not>
18861N/A <available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
18861N/A </not>
18861N/A <then>
18861N/A <mkdir dir="${tmp.dir}"/>
18861N/A
18861N/A <!-- Install STAF -->
18861N/A <echo>Installing staf, please wait...</echo>
18861N/A <mkdir dir="${staf.install.dir}/${staf.name}"/>
18861N/A <if>
18861N/A <equals arg1="${os.family}" arg2="windows"/>
18861N/A <then>
18861N/A <exec executable="${archives.dir}/${staf.archive}"
18861N/A resultproperty="rc">
18861N/A <arg value="-i"/>
18861N/A <arg value="silent"/>
18861N/A <arg value="-DACCEPT_LICENSE=1"/>
18861N/A <arg value="-DUSER_INSTALL_DIR=${staf.install.dir}/${staf.name}"/>
18861N/A <arg value="-DREGISTER=0"/>
18861N/A <arg value="-DUPDATE_ENVIRONMENT=User"/>
18861N/A <arg value="-DSTART_ON_LOGIN=0"/>
18861N/A <arg value="-DSCREATE_START_MENU_ICONS=0"/>
18861N/A </exec>
18861N/A </then>
18861N/A <else>
18861N/A <gunzip src="${archives.dir}/${staf.archive}" dest="${tmp.dir}"/>
18861N/A <untar dest="${tmp.dir}">
18861N/A <fileset dir="${tmp.dir}">
18861N/A <include name="*.tar"/>
18861N/A </fileset>
18861N/A </untar>
18861N/A <chmod file="${tmp.dir}/staf/STAFInst" perm="755"/>
19142N/A <exec executable="${tmp.dir}/staf/STAFInst"
18861N/A resultproperty="rc">
18861N/A <arg value="-source"/>
18861N/A <arg value="${tmp.dir}/staf"/>
18861N/A <arg value="-target"/>
18861N/A <arg value="${staf.install.dir}/${staf.name}"/>
18861N/A <arg value="-acceptlicense"/>
18861N/A </exec>
18861N/A <delete dir="${repository.dir}/staf"/>
18861N/A </else>
18861N/A </if>
18861N/A
18861N/A <fail message="STAF installation failed">
18861N/A <condition>
18861N/A <and>
19142N/A <not>
18861N/A <equals arg1="${rc}" arg2="0"/>
18861N/A </not>
18861N/A </and>
18861N/A </condition>
18861N/A </fail>
18861N/A </then>
18861N/A <else>
18861N/A <echo>Staf is already installed in [${staf.install.dir}/${staf.name}]</echo>
18861N/A </else>
18861N/A </if>
18861N/A
18861N/A <!-- Install services -->
18861N/A <echo>Installing services, please wait...</echo>
18861N/A <var name="list" value="${stax.archive},${email.archive}"/>
19142N/A <var name="list" value="${list},${event.archive},${eventmanager.archive}"/>
18861N/A <var name="list" value="${list},${http.archive}"/>
18861N/A <for list="${list}" param="archive">
18861N/A <sequential>
18861N/A <var name="name" unset="true"/>
18861N/A
18861N/A <propertyregex property="name"
18861N/A input="@{archive}"
18861N/A regexp="(.*)V(.*)\..*"
18861N/A select="\1-v\2"
18861N/A casesensitive="true"/>
18861N/A
18861N/A <if>
18861N/A <not>
18861N/A <available file="${staf.install.dir}/${name}"/>
19142N/A </not>
18861N/A <then>
18861N/A <unzip src="${archives.dir}/@{archive}"
18861N/A dest="${staf.install.dir}">
18861N/A <chainedmapper>
18861N/A <flattenmapper/>
18861N/A <globmapper from="*" to="${name}/*"/>
18861N/A <mapper>
18861N/A <globmapper from="*" to="*"/>
18861N/A </mapper>
18861N/A </chainedmapper>
18861N/A </unzip>
18861N/A </then>
18861N/A <else>
18861N/A <echo>${name} is already installed in [${staf.install.dir}/${name}]</echo>
19142N/A </else>
18861N/A </if>
18861N/A </sequential>
18861N/A </for>
18861N/A
18861N/A <delete includeemptydirs="true">
18861N/A <fileset dir="${tmp.dir}" includes="**/*"/>
18861N/A </delete>
18861N/A </target>
18861N/A
18861N/A <!-- Uninstall STAF and services -->
18861N/A <target name="uninstall">
18861N/A <if>
18861N/A <available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
18861N/A <then>
19142N/A <echo>Uninstalling staf, please wait...</echo>
18861N/A <exec executable="${staf.install.dir}/${staf.name}/STAFUninst"/>
18861N/A <delete dir="${staf.install.dir}/${staf.name}"/>
18861N/A </then>
18861N/A <else>
18861N/A <echo>Staf is not installed</echo>
18861N/A </else>
18861N/A </if>
18861N/A </target>
18861N/A
18861N/A <!-- Start STAF -->
18861N/A <target name="start">
18861N/A <!-- Copy staf.cfg -->
18861N/A <mkdir dir="${staf.config.dir}"/>
18861N/A <copy file="${staf.config.stubs}" tofile="${staf.config.file}" overwrite="true">
19142N/A <filterchain>
18861N/A <expandproperties/>
18861N/A </filterchain>
18861N/A </copy>
18861N/A
18861N/A <if>
18861N/A <not>
18861N/A <socket port="${staf.port}" server="${host.name}"/>
18861N/A </not>
18861N/A <then>
18861N/A <var name="cp" value="${project.home}/resource/dsml/lib/j2ee.jar:${project.home}/resource/dsml/lib/jaxb-api.jar:${project.home}/resource/dsml/lib/jaxb-impl.jar:${project.home}/resource/dsml/lib/jaxb-xjc.jar:${project.home}/resource/dsml/lib/jaxb1-impl.jar:${project.home}/resource/dsml/lib/jsr173_1.0_api.jar:${project.home}/resource/dsml/lib/saaj-1.3.jar:${project.home}/resource/dsml/lib/saaj-impl-1.3.jar"/>
18861N/A
18861N/A <echo>Starting staf, please wait...</echo>
18861N/A <exec dir="${staf.bin.dir}"
18861N/A executable="${staf.daemon}"
19142N/A spawn="true">
18861N/A <arg value="${staf.config.file}"/>
18861N/A <env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
18861N/A <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
18861N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:${shared.dir}/resource/svnkit.jar:${cp}:."/>
18861N/A <env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
18861N/A <env key="LANG" value="en_US.ISO8859-1"/>
18861N/A <env key="LC_ALL" value="en_US.ISO8859-1"/>
18861N/A <env key="STAFCODEPAGE" value="LATIN_1"/>
18861N/A <env key="STAF_INSTANCE_NAME" value="STAF"/>
18861N/A </exec>
18861N/A
18861N/A <echo>Waiting for service to become available...</echo>
18861N/A <waitfor maxwait="1"
18861N/A maxwaitunit="minute"
19142N/A checkevery="10"
18861N/A checkeveryunit="second"
18861N/A timeoutproperty="timeout">
18861N/A <socket server="${host.name}" port="${staf.port}"/>
18861N/A </waitfor>
18861N/A
18861N/A <if>
18861N/A <isset property="timeout"/>
18861N/A <then>
18861N/A <fail>"STAF initialisation failed"</fail>
18861N/A </then>
18861N/A <else>
18861N/A <echo>STAF is now ready to serve requests</echo>
18861N/A </else>
18861N/A </if>
19142N/A </then>
18861N/A <else>
18861N/A <echo>Staf is already listening on port [${staf.port}]</echo>
18861N/A </else>
18861N/A </if>
18861N/A </target>
18861N/A
18861N/A <!-- Stop STAF -->
18861N/A <target name="stop">
18861N/A <if>
18861N/A <socket port="${staf.port}" server="${host.name}"/>
18861N/A <then>
18861N/A <echo>Stopping staf, please wait...</echo>
18861N/A <exec executable="${staf.executable}">
18861N/A <arg line="local shutdown shutdown"/>
19142N/A <env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
18861N/A <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
18861N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
18861N/A <env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
18861N/A </exec>
18861N/A
18861N/A <echo>Waiting for service to shutdown gracefully...</echo>
18861N/A <waitfor maxwait="1"
18861N/A maxwaitunit="minute"
18861N/A checkevery="10"
18861N/A checkeveryunit="second"
18861N/A timeoutproperty="timeoutSocketListening">
18861N/A <not>
18861N/A <socket server="${host.name}" port="${staf.port}"/>
18861N/A </not>
19142N/A </waitfor>
18861N/A
18861N/A <echo>STAF stopped</echo>
18861N/A </then>
18861N/A <else>
18861N/A <echo>Staf is not running</echo>
18861N/A </else>
18861N/A </if>
18861N/A </target>
18861N/A
18861N/A <!-- Display STAF status -->
18861N/A <target name="status">
18861N/A <echo>Operating System Family - ${os.myname}</echo>
18861N/A <echo>Operating System Name - ${os.name}</echo>
18861N/A <echo>Operating System Version - ${os.version}</echo>
19142N/A <echo>Machine Architecture - ${os.arch}</echo>
18861N/A <echo>Java Home - ${java.path}</echo>
18861N/A <echo>Java Version - ${java.version}</echo>
18861N/A
18861N/A <echo></echo>
18861N/A <if>
18861N/A <available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
18861N/A <then>
18861N/A <echo>Staf is installed in [${staf.install.dir}/${staf.name}]</echo>
18861N/A </then>
18861N/A <else>
18861N/A <echo>Staf is not installed</echo>
18861N/A </else>
18861N/A </if>
18861N/A <if>
19142N/A <socket port="${staf.port}" server="${host.name}"/>
18861N/A <then>
18861N/A <echo>Staf is listening on port [${staf.port}]</echo>
18861N/A </then>
18861N/A <else>
18861N/A <echo>Staf is not running</echo>
18861N/A </else>
18861N/A </if>
18861N/A
18861N/A <echo></echo>
18861N/A <var name="list" value="${stax.archive},${email.archive}"/>
18861N/A <var name="list" value="${list},${event.archive},${eventmanager.archive}"/>
18861N/A <var name="list" value="${list},${http.archive}"/>
18861N/A <for list="${list}" param="archive">
18861N/A <sequential>
19142N/A <var name="shortname" unset="true"/>
18861N/A <var name="name" unset="true"/>
18861N/A
18861N/A <propertyregex property="shortname"
18861N/A input="@{archive}"
18861N/A regexp="(.*)V.*\..*"
18861N/A select="\1"
18861N/A casesensitive="true"/>
18861N/A
18861N/A <propertyregex property="name"
18861N/A input="@{archive}"
18861N/A regexp="(.*)V(.*)\..*"
18861N/A select="\1-v\2"
18861N/A casesensitive="true"/>
18861N/A
19142N/A <if>
18861N/A <not>
18861N/A <available file="${staf.install.dir}/${name}"/>
18861N/A </not>
18861N/A <then>
18861N/A <echo>${shortname} is not installed</echo>
18861N/A </then>
18861N/A <else>
18861N/A <echo>${shortname} is installed in [${staf.install.dir}/${name}]</echo>
18861N/A </else>
18861N/A </if>
18861N/A </sequential>
18861N/A </for>
18861N/A </target>
18861N/A
19142N/A <!-- Display STAF gui -->
18861N/A <target name="gui">
18861N/A <exec dir="${staf.install.dir}/${staf.name}"
18861N/A executable="${java.path}/bin/java"
18861N/A spawn="true">
18861N/A <env key="${var.path}" path="${java.path}$/bin:${staf.install.dir}/${staf.name}/bin"/>
18861N/A <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
18861N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
18861N/A <env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
18861N/A <arg value="-classpath"/>
18861N/A <arg value="${staf.install.dir}/${stax.name}/STAXMon.jar:${staf.lib.dir}/JSTAF.jar"/>
19142N/A <arg value="com.ibm.staf.service.stax.STAXMonitor"/>
18861N/A </exec>
18861N/A </target>
18861N/A
18861N/A <!-- Display jvmlogs -->
18861N/A <target name="jvmlogs">
18861N/A <exec dir="${staf.install.dir}/${staf.name}"
18861N/A executable="${java.path}/bin/java"
18861N/A spawn="true">
18861N/A <env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
18861N/A <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
18861N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
18861N/A <env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
18861N/A <arg value="-classpath"/>
18861N/A <arg value="${staf.lib.dir}${path.separator}${staf.lib.dir}/JSTAF.jar"/>
18861N/A <arg value="com.ibm.staf.STAFJVMLogViewer"/>
18861N/A </exec>
18861N/A </target>
18861N/A</project>
18861N/A