<project name="bootstrapPluginsIIS6Uninstall" default="validateAntCall" basedir=".">

   <!--
# IBM Confidential OCO Source Material
# 5639-D57, 5630-A36, 5630-A37, 5724-D18 (C) COPYRIGHT International Business Machines Corp. 1997, 2009
# The source code for this program is not published or otherwise divested
# of its trade secrets, irrespective of what has been deposited with the
# U.S. Copyright Office.
   -->
   
<!-- Need to NOT indent these lines.  Updates webserver specific logfile -->    
   <!-- 
   ***************************************************************************
   TARGET: updateLogFile
   Log statement to webserver uninstall log
   ***************************************************************************
   -->      
<target name="updateLogFile"
        description="Update webserver specific logfile">
<property name="CRLF" value="&#13;&#10;"/>                        
<echo file="${install.log}" append="true">${stringToAppend}${CRLF}</echo>
</target>
   
   <!-- 
   ***************************************************************************
   TARGET: updateLogFile
   Log statement to webserver uninstall log and stdout
   ***************************************************************************
   -->      
    <target name="logBoth">
       <echo>${logStatement}</echo>
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="${logStatement}"/>
        </antcall>            
    </target>    

   <!-- 
   ***************************************************************************
   TARGET: logStartupProperties
   Log startup properties to the uninstall log
   ***************************************************************************
   -->      
    <target name="logStartupProperties"
            description="Log properties passed to script">
        <property name="install.log" value="${PLUGIN_HOME}\logs\unconfig\uninstallIIS6Plugin.log"/> 
        <mkdir dir="${PLUGIN_HOME}\logs\unconfig"/>
        <touch file="${install.log}"/>
        <tstamp>
           <format property="timestamp" pattern="MM/dd/yyyy hh:mm aa"/>
        </tstamp>
        <antcall target="updateLogFile">
           <param name="stringToAppend" value=" "/>
        </antcall>        
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="************************************************************"/>
        </antcall>        
        
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="** Uninstall IIS6 Webserver Plugin ${timestamp}"/>
        </antcall>     
        
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="************************************************************"/>
        </antcall>        
       
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="PLUGIN_HOME = ${PLUGIN_HOME}"/>
        </antcall>   
          
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="OS_NAME = ${OS_NAME}"/>
        </antcall>     
        
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="WEBSERVER_TYPE = ${WEBSERVER_TYPE}"/>
        </antcall>     
        
        <antcall target="updateLogFile">
           <param name="stringToAppend" value="PLUGIN_UNCONFIGURE_IIS6 = ${PLUGIN_CONFIGURE_IIS6}"/>
        </antcall>     
        
        
    </target>
    <!--
    **************************************************************************
    TARGET: Usage
    Displays usage information
    **************************************************************************
    -->
    <target name="Usage" if="CMDLINE_CFG"
            description="Display usage information">       
      	<echo message="Usage: -ant -f IIS6UnInstall.ant [[option=optionValue]..]"/>
      	<echo message=""/>
      	<echo message="Valid Options"/>
        <echo message="============="/>
      	<echo message="-DPLUGIN_HOME=pluginDirectory"/>
        <echo message="    required - the location of the plugin home directory"/>
        <echo message="      (ie, c:\Program Files\IBM\WebSphere\Plugins)"/>
                                                            
    </target>                
    <!--
    ***************************************************************************
    TARGET: bootstrapPluginsIIS6Uninstall
    This is the main target
    ***************************************************************************
    -->      
    <target name="bootstrapPluginsIIS6Uninstall"
        description="Uninstall IIS6 Plugin"
        depends="logStartupProperties">
        
        <antcall target="logBoth">
           <param name="logStatement" value="Uninstalling IIS 6 plugin"/>
        </antcall>
        
        <exec dir="${PLUGIN_HOME}/bin" executable="${PLUGIN_HOME}/bin/configureIIS.exe" 
              failonerror="true"
              output="${PLUGIN_HOME}/logs/uninstall/uninstallIIS6Plugin.log">
              <arg value="&quot;-remove&quot; &quot;sePlugins&quot;"/>	
        </exec>    
        
        <antcall target="logBoth">
           <param name="logStatement" value="Uninstall complete"/>
        </antcall>
    </target>
    
    <!--
    **************************************************************************
    TARGET: validateAntCall
    This is the main target. Check that all required config options are present.         
    If all required config options are present set IIS6Target to 
    bootstrapPluginsIIS6Uninstall. Otherwise set IIS6Target to "Usage" so the usage 
    information can be displayed
    ***************************************************************************
    -->
    <target name="validateAntCall"
        description="UnConfigure Plugin">
        
        <condition property="ValidOptions">                   
           <and>                                            
              <equals arg1="${PLUGIN_CONFIGURE_IIS6}" arg2="TRUE" trim="true" casesensitive="false"/>
              <isset property="OS_NAME"/>
              <isset property="PLUGIN_HOME"/>        
              <isset property="WEBSERVER_TYPE"/> 
              <equals arg1="${WEBSERVER_TYPE}" arg2="IIS" trim="true"/>            
           </and>                                           
        </condition>
	
        <condition property="IHSTarget" value="bootstrapPluginsIIS6Uninstall">
           <istrue value="${ValidOptions}"/>
        </condition>
        
        <condition property="IHSTarget" value="Usage">
              <isfalse value="${ValidOptions}"/>
        </condition>
        
        <antcall target="${IHSTarget}"/>  
        
    </target>
    
</project>
