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