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

Open Identity Platform Community
26.24.2024 c1352f0112e915081bc4620e91cfd8671378d763
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
 
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
 
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
 
  Copyright 2006-2008 Sun Microsystems, Inc.
  Portions Copyright 2016 ForgeRock AS.
 ! -->
 
<project name="opends-tests-installer" basedir="." default="usage">
  <description>
        Installer ant file for the server
        This allows tests that need a running instance of the product to easily
        get one.
  </description>
  <!-- this one has to be loaded first since it's used in
    default.installer.properties
  -->
    <property file="../PRODUCT"                                                />
  <property name="product.name"    value="${SHORT_NAME}"                     />
  <property name="product.version" 
            value="${MAJOR_VERSION}.${MINOR_VERSION}.${POINT_VERSION}"       />
    <!-- this is an optional file if you want to pass custom values           -->
    <property file="installer.properties"                                      />
    <!-- this is the file where the default values are defined                -->
    <property file="default.installer.properties"                              />
    <!-- Define default values for mandatory properties in case the
        property files would not be found
    -->
  <condition property="script.ext" value=".bat" else="">
    <os family="windows"/>
  </condition>
  <condition property="bin.dir" value="bat" else="bin">
    <os family="windows"/>
  </condition>
  <!-- Usage section - top -->  
    <target name="usage">
        <echo>Installer usage: 
  status     : reports if product is installed and/or running
main target=
  bootstrap  : installs and configure the product
  wipeout    : stops and uninstalls the product
subtargets=
  install    : installs the product
  configure  : set the server up to listen on a given port
  start      : start the product unless it is already running
  stop       : stop the product if it is already running
  stop.force : stop no matter what
  uninstall  : uninstall the product if it is installed
        </echo>
    </target>
  <!-- Usage section - bottom -->   
    
    <!-- Installation section - top -->
    <target name="install-do" 
            description="deploy the product bits"
            unless="product.installed"          >
      <echo message="Installing ${product.name} ${product.version}..." />
      <property name="config.file"   
                location="${full.install.dir}/config/config.ldif"/>
      <mkdir dir="${install.dir}"/>
      <unzip dest="${install.dir}">
        <fileset dir="${project.home}/build/package">
          <include name="*.zip"/>
        </fileset>
      </unzip>
      <chmod perm="755">
        <fileset dir="${full.install.dir}/bin" />
      </chmod>
    </target>
    
    <target name="install" depends="status-do,install-do"/>
    <!-- end of install related targets -->
    
    <!-- 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" depends="status-do,stop-do,uninstall-do"/>
    <!-- Uninstallation section - bottom -->
    
    <!-- Configuration section - top -->
    <target name="configure-do"
            description="configures product to listen on the right port number"
            if="product.installed" >
      <echo message="basedir=[${basedir}]" />
      <echo message="configuring ${product.name} ${product.version}..." />
      <java fork="true" classname="org.opends.server.tools.ConfigureDS">
        <!-- building the classpath to run the configurator -->
        <classpath>
          <fileset dir="${full.install.dir}/lib">
            <include name="*.jar"/>
          </fileset>
        </classpath>
        
        <!-- provide the arguments here -->
        <jvmarg value="-Dorg.opends.server.scriptName=configure-ds"/>
        <arg value="--configFile"/>
        <arg value="${full.install.dir}/config/config.ldif"/>
        <arg line="-p ${port.ldap}"/>
        <arg value="-D"/>
        <arg value="${bind.dn}"/>
        <arg value="-w"/>
        <arg value="${bind.pwd}"/>
      </java>
    </target>
    
    <target name="configure" depends="status-do,configure-do"/>
    <!-- Configuration section - bottom -->
    
    <!-- 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
        executable="${full.install.dir}${file.separator}${bin.dir}${file.separator}start-ds${script.ext}"
       spawn="true"/>
    </target>
    <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.dir}${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>
    </target>
    <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>
    <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." />
    </target>
      <!-- end of installation status -->
      
      <!-- Running status -->
    <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" if="product.installed" depends="status-do">
      <echo message="Wipeout: removing product" />
      <antcall target="stop.sleep"  />
      <antcall target="uninstall"   />
    </target>
    <!--  end of macros related targets-->
</project>