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