<!--
|
! 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 legal-notices/CDDLv1_0.txt
|
! or http://forgerock.org/license/CDDLv1.0.html.
|
! 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 legal-notices/CDDLv1_0.txt.
|
! 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-2009 Sun Microsystems, Inc.
|
! Portions Copyright 2013 ForgeRock AS
|
! -->
|
<project name="staf">
|
|
<description>
|
Manage STAF (install/uninstall, start/stop).
|
</description>
|
|
<!-- Install STAF and services -->
|
<target name="install">
|
<if>
|
<not>
|
<available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
|
</not>
|
<then>
|
<mkdir dir="${tmp.dir}"/>
|
|
<!-- Install STAF -->
|
<echo>Installing staf, please wait...</echo>
|
<mkdir dir="${staf.install.dir}/${staf.name}"/>
|
<if>
|
<equals arg1="${os.family}" arg2="windows"/>
|
<then>
|
<exec executable="${archives.dir}/${staf.archive}"
|
resultproperty="rc">
|
<arg value="-i"/>
|
<arg value="silent"/>
|
<arg value="-DACCEPT_LICENSE=1"/>
|
<arg value="-DUSER_INSTALL_DIR=${staf.install.dir}/${staf.name}"/>
|
<arg value="-DREGISTER=0"/>
|
<arg value="-DUPDATE_ENVIRONMENT=User"/>
|
<arg value="-DSTART_ON_LOGIN=0"/>
|
<arg value="-DSCREATE_START_MENU_ICONS=0"/>
|
</exec>
|
</then>
|
<else>
|
<gunzip src="${archives.dir}/${staf.archive}" dest="${tmp.dir}"/>
|
<untar dest="${tmp.dir}">
|
<fileset dir="${tmp.dir}">
|
<include name="*.tar"/>
|
</fileset>
|
</untar>
|
<chmod file="${tmp.dir}/staf/STAFInst" perm="755"/>
|
<exec executable="${tmp.dir}/staf/STAFInst"
|
resultproperty="rc">
|
<arg value="-source"/>
|
<arg value="${tmp.dir}/staf"/>
|
<arg value="-target"/>
|
<arg value="${staf.install.dir}/${staf.name}"/>
|
<arg value="-acceptlicense"/>
|
</exec>
|
<delete dir="${repository.dir}/staf"/>
|
</else>
|
</if>
|
|
<fail message="STAF installation failed">
|
<condition>
|
<and>
|
<not>
|
<equals arg1="${rc}" arg2="0"/>
|
</not>
|
</and>
|
</condition>
|
</fail>
|
</then>
|
<else>
|
<echo>Staf is already installed in [${staf.install.dir}/${staf.name}]</echo>
|
</else>
|
</if>
|
|
<!-- Install services -->
|
<echo>Installing services, please wait...</echo>
|
<var name="list" value="${stax.archive},${email.archive}"/>
|
<var name="list" value="${list},${event.archive},${eventmanager.archive}"/>
|
<var name="list" value="${list},${http.archive}"/>
|
<for list="${list}" param="archive">
|
<sequential>
|
<var name="name" unset="true"/>
|
|
<propertyregex property="name"
|
input="@{archive}"
|
regexp="(.*)V(.*)\..*"
|
select="\1-v\2"
|
casesensitive="true"/>
|
|
<if>
|
<not>
|
<available file="${staf.install.dir}/${name}"/>
|
</not>
|
<then>
|
<unzip src="${archives.dir}/@{archive}"
|
dest="${staf.install.dir}">
|
<chainedmapper>
|
<flattenmapper/>
|
<globmapper from="*" to="${name}/*"/>
|
<mapper>
|
<globmapper from="*" to="*"/>
|
</mapper>
|
</chainedmapper>
|
</unzip>
|
</then>
|
<else>
|
<echo>${name} is already installed in [${staf.install.dir}/${name}]</echo>
|
</else>
|
</if>
|
</sequential>
|
</for>
|
|
<delete includeemptydirs="true">
|
<fileset dir="${tmp.dir}" includes="**/*"/>
|
</delete>
|
</target>
|
|
<!-- Uninstall STAF and services -->
|
<target name="uninstall">
|
<if>
|
<available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
|
<then>
|
<echo>Uninstalling staf, please wait...</echo>
|
<exec executable="${staf.install.dir}/${staf.name}/STAFUninst"/>
|
<delete dir="${staf.install.dir}/${staf.name}"/>
|
</then>
|
<else>
|
<echo>Staf is not installed</echo>
|
</else>
|
</if>
|
</target>
|
|
<!-- Start STAF -->
|
<target name="start">
|
<!-- Copy staf.cfg -->
|
<mkdir dir="${staf.config.dir}"/>
|
<copy file="${staf.config.stubs}" tofile="${staf.config.file}" overwrite="true">
|
<filterchain>
|
<expandproperties/>
|
</filterchain>
|
</copy>
|
|
<if>
|
<not>
|
<socket port="${staf.port}" server="${host.name}"/>
|
</not>
|
<then>
|
<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"/>
|
|
<echo>Starting staf, please wait...</echo>
|
<exec dir="${staf.bin.dir}"
|
executable="${staf.daemon}"
|
spawn="true">
|
<arg value="${staf.config.file}"/>
|
<env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
|
<env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
|
<env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:${shared.dir}/resource/svnkit.jar:${cp}:."/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
|
<env key="LANG" value="en_US.ISO8859-1"/>
|
<env key="LC_ALL" value="en_US.ISO8859-1"/>
|
<env key="STAFCODEPAGE" value="LATIN_1"/>
|
<env key="STAF_INSTANCE_NAME" value="STAF"/>
|
</exec>
|
|
<echo>Waiting for service to become available...</echo>
|
<waitfor maxwait="1"
|
maxwaitunit="minute"
|
checkevery="10"
|
checkeveryunit="second"
|
timeoutproperty="timeout">
|
<socket server="${host.name}" port="${staf.port}"/>
|
</waitfor>
|
|
<if>
|
<isset property="timeout"/>
|
<then>
|
<fail>"STAF initialisation failed"</fail>
|
</then>
|
<else>
|
<echo>STAF is now ready to serve requests</echo>
|
</else>
|
</if>
|
</then>
|
<else>
|
<echo>Staf is already listening on port [${staf.port}]</echo>
|
</else>
|
</if>
|
</target>
|
|
<!-- Stop STAF -->
|
<target name="stop">
|
<if>
|
<socket port="${staf.port}" server="${host.name}"/>
|
<then>
|
<echo>Stopping staf, please wait...</echo>
|
<exec executable="${staf.executable}">
|
<arg line="local shutdown shutdown"/>
|
<env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
|
<env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
|
<env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
|
</exec>
|
|
<echo>Waiting for service to shutdown gracefully...</echo>
|
<waitfor maxwait="1"
|
maxwaitunit="minute"
|
checkevery="10"
|
checkeveryunit="second"
|
timeoutproperty="timeoutSocketListening">
|
<not>
|
<socket server="${host.name}" port="${staf.port}"/>
|
</not>
|
</waitfor>
|
|
<echo>STAF stopped</echo>
|
</then>
|
<else>
|
<echo>Staf is not running</echo>
|
</else>
|
</if>
|
</target>
|
|
<!-- Display STAF status -->
|
<target name="status">
|
<echo>Operating System Family - ${os.myname}</echo>
|
<echo>Operating System Name - ${os.name}</echo>
|
<echo>Operating System Version - ${os.version}</echo>
|
<echo>Machine Architecture - ${os.arch}</echo>
|
<echo>Java Home - ${java.path}</echo>
|
<echo>Java Version - ${java.version}</echo>
|
|
<echo></echo>
|
<if>
|
<available file="${staf.install.dir}/${staf.name}/bin/STAF.cfg"/>
|
<then>
|
<echo>Staf is installed in [${staf.install.dir}/${staf.name}]</echo>
|
</then>
|
<else>
|
<echo>Staf is not installed</echo>
|
</else>
|
</if>
|
<if>
|
<socket port="${staf.port}" server="${host.name}"/>
|
<then>
|
<echo>Staf is listening on port [${staf.port}]</echo>
|
</then>
|
<else>
|
<echo>Staf is not running</echo>
|
</else>
|
</if>
|
|
<echo></echo>
|
<var name="list" value="${stax.archive},${email.archive}"/>
|
<var name="list" value="${list},${event.archive},${eventmanager.archive}"/>
|
<var name="list" value="${list},${http.archive}"/>
|
<for list="${list}" param="archive">
|
<sequential>
|
<var name="shortname" unset="true"/>
|
<var name="name" unset="true"/>
|
|
<propertyregex property="shortname"
|
input="@{archive}"
|
regexp="(.*)V.*\..*"
|
select="\1"
|
casesensitive="true"/>
|
|
<propertyregex property="name"
|
input="@{archive}"
|
regexp="(.*)V(.*)\..*"
|
select="\1-v\2"
|
casesensitive="true"/>
|
|
<if>
|
<not>
|
<available file="${staf.install.dir}/${name}"/>
|
</not>
|
<then>
|
<echo>${shortname} is not installed</echo>
|
</then>
|
<else>
|
<echo>${shortname} is installed in [${staf.install.dir}/${name}]</echo>
|
</else>
|
</if>
|
</sequential>
|
</for>
|
</target>
|
|
<!-- Display STAF gui -->
|
<target name="gui">
|
<exec dir="${staf.install.dir}/${staf.name}"
|
executable="${java.path}/bin/java"
|
spawn="true">
|
<env key="${var.path}" path="${java.path}$/bin:${staf.install.dir}/${staf.name}/bin"/>
|
<env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
|
<env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
|
<arg value="-classpath"/>
|
<arg value="${staf.install.dir}/${stax.name}/STAXMon.jar:${staf.lib.dir}/JSTAF.jar"/>
|
<arg value="com.ibm.staf.service.stax.STAXMonitor"/>
|
</exec>
|
</target>
|
|
<!-- Display jvmlogs -->
|
<target name="jvmlogs">
|
<exec dir="${staf.install.dir}/${staf.name}"
|
executable="${java.path}/bin/java"
|
spawn="true">
|
<env key="${var.path}" path="${java.path}/bin:${staf.install.dir}/${staf.name}/bin"/>
|
<env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
|
<env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
|
<arg value="-classpath"/>
|
<arg value="${staf.lib.dir}${path.separator}${staf.lib.dir}/JSTAF.jar"/>
|
<arg value="com.ibm.staf.STAFJVMLogViewer"/>
|
</exec>
|
</target>
|
</project>
|