mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

al_xipe
14.38.2007 38bdc0d97be50d62fc7f18561480685808a50217
refactoring in the installer to make it easier to maintain
1 files modified
178 ■■■■■ changed files
opendj-sdk/opends/tests/installer.xml 178 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/installer.xml
@@ -45,7 +45,15 @@
    <!-- Define default values for mandatory properties in case the
        property files would not be found
    -->
  <condition property="script.ext" value=".bat">
    <os family="windows"/>
  </condition>
  <condition property="script.ext" value="">
    <not>
      <isset property="script.ext"/>
    </not>
  </condition>
  <!-- Usage section - top -->
    <target name="usage">
        <echo>Installer usage: 
  status     : reports if product is installed and/or running
@@ -61,9 +69,10 @@
  uninstall  : uninstall the product if it is installed
        </echo>
    </target>
  <!-- Usage section - bottom -->
    
    <!-- Installation -->
    <target name="install.do"
    <!-- Installation section - top -->
    <target name="install-do"
          description="deploy the product bits"
                    unless="product.installed"          >
        <echo message="Installing ${product.name} ${product.version}..." />
@@ -82,33 +91,21 @@
    </chmod>
  </target>
    
    <target name="install" >
    <available file="${full.install.dir}"
              type="dir"
              property="product.installed" />
        <antcall target="install.do"           />
    </target>
    <target name="install" depends="status-do,install-do"/>
    <!-- end of install related targets -->
    
    <!-- Uninstallation -->
  <target name="uninstall.do"
    <!-- Uninstallation section - top -->
    <target name="uninstall-do"
          description="Uninstall the product"
                    if="product.installed"            >
        <echo message="Uninstalling ${product.name} ${product.version}..." />
    <delete dir="${install.dir}" />
  </target>
    <target name="uninstall">
    <available file="${full.install.dir}"
              type="dir"
              property="product.installed" />
        <antcall target="uninstall.do"         />
    </target>
    <!-- end of uninstall related targets -->
    <target name="uninstall" depends="status-do,stop-do,uninstall-do"/>
    <!-- Uninstallation section - bottom -->
    
    <!-- configuration -->
  <target name="configure.do"
    <!-- Configuration secton - top -->
    <target name="configure-do"
          description="configures product to listen on the right port number"
                    if="product.installed" >
    <echo message="basedir=[${basedir}]" />
@@ -135,93 +132,69 @@
    </java>
  </target>
    
    <target name="configure">
    <available file="${full.install.dir}"
              type="dir"
              property="product.installed" />
        <antcall target="configure.do" />
    </target>
    <!-- end of config related targets -->
    <target name="configure" depends="status-do,configure-do"/>
    <!-- Configuration section - bottom -->
    
    <!-- start -->
  <target name="start.do"
    <!-- Start section - top -->
    <target name="start-do"
          description="start the product" 
          if="product.installed"
          unless="product.running" >
        <echo message="Starting ${product.name} ${product.version}... on ${os.name}" />
    <exec
      os="${windows.list}"
      executable="${full.install.dir}\bin\start-ds.bat"
     spawn="true"                                                           />
    <exec
      os="${unix.list}"
      executable="${full.install.dir}/bin/start-ds"
        executable="${full.install.dir}${file.separator}bin${file.separator}start-ds${script.ext}"
      spawn="true"                                                           />
  </target>
    <target name="start">
    <target name="start" depends="status-do,start-do"/>
    <!--  Start section - bottom -->
  <!-- Stop section - top -->
    <target name="stop.force"
            description="stop the server">
      <echo message="Stopping ${product.name} ${product.version}..." />
      <exec
        executable="${full.install.dir}${file.separator}bin${file.separator}stop-ds${script.ext}"
        spawn="true">
        <arg line="-h ${host.name}"/>
        <arg line="-p ${port.ldap}"/>
        <arg line="-w ${bind.pwd}" />
        <arg value="-D"            />
        <arg value="${bind.dn}"    />
      </exec>
    </target>
    <target name="stop-do" if="product.running">
      <antcall target="stop.force" />
    </target>
    <target name="stop" depends="status-do,stop-do"/>
    <target name="sleep" if="product.running">
      <echo message="Give the server some time to shut down and release locks..." />
      <sleep seconds="10"         />
    </target>
    <target name="stop.sleep" depends="stop,sleep"/>
  <!-- Stop section - bottom -->
    <!-- Status section - top -->
    <target name="status-do" description="gather status">
    <available file="${full.install.dir}" 
              type="dir" 
              property="product.installed" />
    <condition property="product.running">
      <socket port="${port.ldap}" server="${host.name}"/>
    </condition>
        <antcall target="start.do" />
    </target>   
    <!--  end of start related targets -->
  <!-- stop  -->
  <target name="stop.force"
          description="stop the server">
        <echo message="Stopping ${product.name} ${product.version}..." />
    <exec
      os="${windows.list}"
      executable="${full.install.dir}\bin\stop-ds.bat"
      spawn="true">
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${bind.pwd}" />
      <arg value="-D"            />
      <arg value="${bind.dn}"    />
    </exec>
    <exec
      os="${unix.list}"
      executable="${full.install.dir}/bin/stop-ds"
      spawn="true"                                   >
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${bind.pwd}" />
      <arg value="-D"            />
      <arg value="${bind.dn}"    />
    </exec>
    <target name="is-product-running?" if="product.running">
      <echo message="${product.name} is listening on port [${port.ldap}]"/>
  </target>
    <target name="stop.do" if="product.running">
        <antcall target="stop.force" />
    <target name="is-product-not-running?" unless="product.running">
      <echo message="${product.name} is NOT running"/>
    </target>
  <target name="stop" >
    <condition property="product.running">
      <socket port="${port.ldap}" server="${host.name}"/>
    </condition>
        <antcall target="stop.do" />
    </target>
  <target name="sleep" if="product.running">
    <echo message="Give the server some time to shut down and release locks..." />
    <sleep seconds="10"         />
  </target>
  <target name="stop.sleep" >
    <condition property="product.running">
      <socket port="${port.ldap}" server="${host.name}"/>
    </condition>
        <antcall target="stop.do" />
    <antcall target="sleep" />
    </target>
    <!-- end of stop related targets -->
    <!-- status -->
      <!-- Installation status -->
    <target name="is-product-installed?" if="product.installed">
        <echo message="Found ${product.name} installed in [${full.install.dir}]" />
      <antcall target="is-product-running?"/>
      <antcall target="is-product-not-running?"/>
    </target>
    <target name="is-product-not-installed?" unless="product.installed">
        <echo message="Could not find ${product.name} installation." />
@@ -229,38 +202,21 @@
        <!-- end of installation status -->
        
        <!-- Running status -->
  <target name="is-product-running?" if="product.running">
    <echo message="${product.name} is listening on port [${port.ldap}]"/>
  </target>
  <target name="is-product-not-running?" unless="product.running">
    <echo message="${product.name} is NOT running"/>
  </target>
        <!-- end of running status -->
    <target name="status">
    <available file="${full.install.dir}"
              type="dir"
              property="product.installed" />
    <condition property="product.running">
      <socket port="${port.ldap}" server="${host.name}"/>
    </condition>
        <antcall target="is-product-installed?"     />
        <antcall target="is-product-not-installed?" />
        <antcall target="is-product-running?"       />
        <antcall target="is-product-not-running?"   />
    </target>
    <!--  end of status related tasks -->
    <target name="status" depends="status-do,is-product-installed?,is-product-not-installed?"/>
    <!--  Status section - bottom -->
    <!-- macros - chained operations -->
    <target name="bootstrap">
        <echo message="Bootstrap: wipe the plate clean in case there is a previous install"/>
        <antcall target="wipeout" />
        <echo message="Bootstrap: install the product" />
        <antcall target="install"   />
        <antcall target="configure" />
        <antcall target="start"     />
    </target>
    
    <target name="wipeout">
    <target name="wipeout" if="product.installed" depends="status-do">
      <echo message="Wipeout: removing product" />
        <antcall target="stop.sleep"  />
        <antcall target="uninstall"   />