445N/A<!--
445N/A ! CDDL HEADER START
445N/A !
445N/A ! The contents of this file are subject to the terms of the
445N/A ! Common Development and Distribution License, Version 1.0 only
445N/A ! (the "License"). You may not use this file except in compliance
445N/A ! with the License.
445N/A !
445N/A ! You can obtain a copy of the license at
445N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
445N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
445N/A ! See the License for the specific language governing permissions
445N/A ! and limitations under the License.
445N/A !
445N/A ! When distributing Covered Code, include this CDDL HEADER in each
445N/A ! file and include the License file at
445N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
445N/A ! add the following below this CDDL HEADER, with the fields enclosed
873N/A ! by brackets "[]" replaced with your own identifying information:
445N/A ! Portions Copyright [yyyy] [name of copyright owner]
445N/A !
445N/A ! CDDL HEADER END
445N/A !
445N/A !
3215N/A ! Copyright 2006-2008 Sun Microsystems, Inc.
445N/A ! -->
445N/A
445N/A<project name="opends-tests-installer" basedir="." default="usage">
445N/A <description>
445N/A Installer ant file for the server
445N/A This allows tests that need a running instance of the product to easily
445N/A get one.
445N/A </description>
445N/A <!-- this one has to be loaded first since it's used in
445N/A default.installer.properties
445N/A -->
482N/A <property file="/PRODUCT" />
482N/A <property name="product.name" value="${SHORT_NAME}" />
482N/A <property name="product.version"
1960N/A value="${MAJOR_VERSION}.${MINOR_VERSION}.${POINT_VERSION}" />
482N/A <!-- this is an optional file if you want to pass custom values -->
482N/A <property file="installer.properties" />
482N/A <!-- this is the file where the default values are defined -->
482N/A <property file="default.installer.properties" />
445N/A <!-- Define default values for mandatory properties in case the
445N/A property files would not be found
445N/A -->
1960N/A <condition property="script.ext" value=".bat" else="">
788N/A <os family="windows"/>
788N/A </condition>
1960N/A <condition property="bin.dir" value="bat" else="bin">
1960N/A <os family="windows"/>
788N/A </condition>
788N/A <!-- Usage section - top -->
445N/A <target name="usage">
445N/A <echo>Installer usage:
445N/A status : reports if product is installed and/or running
445N/Amain target=
445N/A bootstrap : installs and configure the product
445N/A wipeout : stops and uninstalls the product
445N/Asubtargets=
445N/A install : installs the product
445N/A configure : set the server up to listen on a given port
445N/A start : start the product unless it is already running
445N/A stop : stop the product if it is already running
445N/A stop.force : stop no matter what
445N/A uninstall : uninstall the product if it is installed
445N/A </echo>
445N/A </target>
788N/A <!-- Usage section - bottom -->
445N/A
788N/A <!-- Installation section - top -->
788N/A <target name="install-do"
788N/A description="deploy the product bits"
788N/A unless="product.installed" >
788N/A <echo message="Installing ${product.name} ${product.version}..." />
788N/A <property name="config.file"
788N/A location="${full.install.dir}/config/config.ldif"/>
788N/A <mkdir dir="${install.dir}"/>
788N/A <unzip dest="${install.dir}">
788N/A <fileset dir="${project.home}/build/package">
788N/A <include name="*.zip"/>
788N/A </fileset>
788N/A </unzip>
788N/A <chmod perm="755">
1960N/A <fileset dir="${full.install.dir}/bin" />
788N/A </chmod>
788N/A </target>
788N/A
788N/A <target name="install" depends="status-do,install-do"/>
445N/A <!-- end of install related targets -->
445N/A
788N/A <!-- Uninstallation section - top -->
788N/A <target name="uninstall-do"
788N/A description="Uninstall the product"
788N/A if="product.installed">
788N/A <echo message="Uninstalling ${product.name} ${product.version}..." />
788N/A <delete dir="${install.dir}" />
788N/A </target>
788N/A <target name="uninstall" depends="status-do,stop-do,uninstall-do"/>
788N/A <!-- Uninstallation section - bottom -->
445N/A
3247N/A <!-- Configuration section - top -->
788N/A <target name="configure-do"
788N/A description="configures product to listen on the right port number"
788N/A if="product.installed" >
788N/A <echo message="basedir=[${basedir}]" />
788N/A <echo message="configuring ${product.name} ${product.version}..." />
788N/A <java fork="true" classname="org.opends.server.tools.ConfigureDS">
788N/A <!-- building the classpath to run the configurator -->
788N/A <classpath>
788N/A <fileset dir="${full.install.dir}/lib">
788N/A <include name="*.jar"/>
788N/A </fileset>
788N/A </classpath>
788N/A
788N/A <!-- provide the arguments here -->
788N/A <jvmarg value="-Dorg.opends.server.scriptName=configure-ds"/>
788N/A <arg value="--configClass"/>
788N/A <arg value="org.opends.server.extensions.ConfigFileHandler"/>
788N/A <arg value="--configFile"/>
788N/A <arg value="${full.install.dir}/config/config.ldif"/>
788N/A <arg line="-p ${port.ldap}"/>
788N/A <arg value="-D"/>
788N/A <arg value="${bind.dn}"/>
788N/A <arg value="-w"/>
788N/A <arg value="${bind.pwd}"/>
788N/A </java>
788N/A </target>
788N/A
788N/A <target name="configure" depends="status-do,configure-do"/>
788N/A <!-- Configuration section - bottom -->
445N/A
788N/A <!-- Start section - top -->
788N/A <target name="start-do"
788N/A description="start the product"
788N/A if="product.installed"
788N/A unless="product.running" >
788N/A <echo message="Starting ${product.name} ${product.version}... on ${os.name}" />
788N/A <exec
1960N/A executable="${full.install.dir}${file.separator}${bin.dir}${file.separator}start-ds${script.ext}"
788N/A spawn="true"/>
788N/A </target>
788N/A <target name="start" depends="status-do,start-do"/>
788N/A <!-- Start section - bottom -->
445N/A
788N/A <!-- Stop section - top -->
788N/A <target name="stop.force"
788N/A description="stop the server">
788N/A <echo message="Stopping ${product.name} ${product.version}..." />
788N/A <exec
1960N/A executable="${full.install.dir}${file.separator}${bin.dir}${file.separator}stop-ds${script.ext}"
788N/A spawn="true">
788N/A <arg line="-h ${host.name}"/>
788N/A <arg line="-p ${port.ldap}"/>
788N/A <arg line="-w ${bind.pwd}" />
788N/A <arg value="-D" />
788N/A <arg value="${bind.dn}" />
788N/A </exec>
788N/A </target>
788N/A
788N/A <target name="stop-do" if="product.running">
788N/A <antcall target="stop.force" />
788N/A </target>
788N/A
788N/A <target name="stop" depends="status-do,stop-do"/>
455N/A
788N/A <target name="sleep" if="product.running">
788N/A <echo message="Give the server some time to shut down and release locks..." />
788N/A <sleep seconds="10" />
788N/A </target>
788N/A <target name="stop.sleep" depends="stop,sleep"/>
788N/A <!-- Stop section - bottom -->
445N/A
788N/A <!-- Status section - top -->
788N/A <target name="status-do" description="gather status">
788N/A <available file="${full.install.dir}"
788N/A type="dir"
788N/A property="product.installed" />
788N/A <condition property="product.running">
788N/A <socket port="${port.ldap}" server="${host.name}"/>
788N/A </condition>
788N/A </target>
788N/A <target name="is-product-running?" if="product.running">
788N/A <echo message="${product.name} is listening on port [${port.ldap}]"/>
788N/A </target>
788N/A <target name="is-product-not-running?" unless="product.running">
788N/A <echo message="${product.name} is NOT running"/>
788N/A </target>
788N/A <target name="is-product-installed?" if="product.installed">
788N/A <echo message="Found ${product.name} installed in [${full.install.dir}]" />
788N/A <antcall target="is-product-running?"/>
788N/A <antcall target="is-product-not-running?"/>
788N/A </target>
788N/A <target name="is-product-not-installed?" unless="product.installed">
788N/A <echo message="Could not find ${product.name} installation." />
788N/A </target>
788N/A <!-- end of installation status -->
788N/A
788N/A <!-- Running status -->
788N/A <target name="status" depends="status-do,is-product-installed?,is-product-not-installed?"/>
788N/A <!-- Status section - bottom -->
445N/A
445N/A <!-- macros - chained operations -->
788N/A <target name="bootstrap">
788N/A <echo message="Bootstrap: wipe the plate clean in case there is a previous install"/>
788N/A <antcall target="wipeout" />
788N/A
788N/A <echo message="Bootstrap: install the product" />
788N/A <antcall target="install" />
788N/A <antcall target="configure" />
788N/A <antcall target="start" />
788N/A </target>
788N/A
788N/A <target name="wipeout" if="product.installed" depends="status-do">
788N/A <echo message="Wipeout: removing product" />
788N/A <antcall target="stop.sleep" />
788N/A <antcall target="uninstall" />
788N/A </target>
445N/A <!-- end of macros related targets-->
445N/A</project>