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

jcambon
28.01.2009 bd458262d71f8a331082e8b4d00a2f47b0eaa3fd
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !
 !      Copyright 2008 Sun Microsystems, Inc.
 ! -->
<project name="staf">
 
  <description>
    Manage STAF (install/uninstall, start/stop).
  </description>
 
  <!-- Install STAF and services -->
  <target name="install">
    <if>
      <not>
        <available file="${staf.install.dir}/bin/STAF.cfg"/>
      </not>
      <then>
        <mkdir dir="${tmp.dir}"/>
 
        <!-- Install STAF -->
        <echo>Installing staf, please wait...</echo>
        <mkdir dir="${staf.install.dir}"/>
        <gunzip src="${archives.dir}/${staf.archive}" dest="${tmp.dir}"/>
        <untar dest="${tmp.dir}">
          <fileset dir="${tmp.dir}">
            <include name="*.tar"/>
          </fileset>
        </untar>
        <chmod file="${tmp.dir}/staf/STAFInst" perm="755"/>
        <exec executable="${tmp.dir}/staf/STAFInst">
          <arg value="-source"/>
          <arg value="${tmp.dir}/staf"/>
          <arg value="-target"/>
          <arg value="${staf.install.dir}"/>
          <arg value="-acceptlicense"/>
        </exec>
        <delete dir="${repository.dir}/staf"/>
 
        <!-- Install services -->
        <echo>Installing services, please wait...</echo>
        <mkdir dir="${staf.install.dir}/services"/>
        <unzip src="${archives.dir}/${email.archive}"
           dest="${staf.install.dir}/services"/>
        <unzip src="${archives.dir}/${event.archive}"
           dest="${staf.install.dir}/services"/>
        <unzip src="${archives.dir}/${eventmanager.archive}"
           dest="${staf.install.dir}/services"/>
        <unzip src="${archives.dir}/${stax.archive}"
           dest="${staf.install.dir}/services"/>
        <unzip src="${archives.dir}/${http.archive}"
           dest="${staf.install.dir}/services"/>
 
        <!-- Add DSML service extension -->
        <mkdir dir="${staf.install.dir}/services/dsml"/>
        <copy todir="${staf.install.dir}/services/dsml">
          <fileset dir="${basedir}/../staf-tests/shared/dsml"
               includes="dsmlService.jar"/>
        </copy>
 
        <delete includeemptydirs="true">
          <fileset dir="${tmp.dir}" includes="**/*"/>
        </delete>
      </then>
      <else>
        <echo>Staf is already installed in [${staf.install.dir}]</echo>
      </else>
    </if>
 
    <!-- Copy functional-tests.cfg -->
    <mkdir dir="${staf.config.dir}"/>
    <copy file="${staf.config.stubs}" tofile="${staf.config.file}">
      <filterchain>
        <expandproperties/>
      </filterchain>
    </copy>
  </target>
 
  <!-- Uninstall STAF and services -->
  <target name="uninstall">
    <if>
      <available file="${staf.install.dir}/bin/STAF.cfg"/>
      <then>
        <echo>Uninstalling staf, please wait...</echo>
        <exec executable="${staf.install.dir}/STAFUninst"/>
        <delete dir="${staf.install.dir}"/>
      </then>
      <else>
        <echo>Staf is not installed</echo>
      </else>
    </if>
  </target>
 
  <!-- Start STAF -->
  <target name="start">
    <if>
      <not>
        <socket port="${staf.port}" server="${host.name}"/>
      </not>
      <then>
        <echo>Starting staf, please wait...</echo>
        <exec dir="${staf.bin.dir}"
              executable="${staf.daemon}"
              spawn="true">
          <arg value="${staf.config.file}"/>
          <env key="${var.path}" path="${java.path}${file.separator}bin${path.separator}${staf.install.dir}${file.separator}bin"/>
          <env key="LD_LIBRARY_PATH" path="${staf.install.dir}/lib"/>
          <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}:${project.home}/ext/svnkit/svnkit.jar:."/>
          <env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
          <env key="STAFCODEPAGE" value="LATIN_1"/>
          <env key="STAF_INSTANCE_NAME" value="STAF"/>
        </exec>
 
        <echo>Waiting for service to become available...</echo>
        <waitfor maxwait="3"
             maxwaitunit="minute"
             checkevery="10"
             checkeveryunit="second"
             timeoutproperty="timeout">
          <socket server="${host.name}" port="${staf.port}"/>
        </waitfor>
 
        <echo>STAF is now ready to serve requests</echo>
      </then>
      <else>
        <echo>Staf is already listening on port [${staf.port}]</echo>
      </else>
    </if>
  </target>
 
  <!-- Stop STAF -->
  <target name="stop">
    <if>
      <socket port="${staf.port}" server="${host.name}"/>
      <then>
        <echo>Stopping staf, please wait...</echo>
        <exec executable="${staf.executable}">
          <arg line="local shutdown shutdown"/>
          <env key="${var.path}" path="${java.path}${file.separator}bin${path.separator}${staf.install.dir}${file.separator}bin"/>
          <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
          <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}:."/>
          <env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
          <env key="STAFCODEPAGE" value="LATIN_1"/>
        </exec>
 
        <echo>Waiting for service to shutdown gracefully...</echo>
        <waitfor maxwait="3"
             maxwaitunit="minute"
             checkevery="10"
             checkeveryunit="second"
             timeoutproperty="timeoutSocketListening">
          <not>
            <socket server="${host.name}" port="${staf.port}"/>
          </not>
        </waitfor>
 
        <echo>STAF stopped</echo>
      </then>
      <else>
        <echo>Staf is not running</echo>
      </else>
    </if>
  </target>
 
  <!-- Display STAF status -->
  <target name="status">
    <echo>Operating System Family  - ${os.myname}</echo>
    <echo>Operating System Name    - ${os.name}</echo>
    <echo>Operating System Version - ${os.version}</echo>
    <echo>Machine Architecture     - ${os.arch}</echo>
    <echo>Java Home                - ${java.path}</echo>
    <echo>Java Version             - ${java.version}</echo>
 
    <echo></echo>
    <if>
      <available file="${staf.install.dir}/bin/STAF.cfg"/>
      <then>
 
        <echo>Staf is installed in [${staf.install.dir}]</echo>
      </then>
      <else>
        <echo>Staf is not installed</echo>
      </else>
    </if>
 
    <echo></echo>
    <if>
      <socket port="${staf.port}" server="${host.name}"/>
      <then>
        <echo>Staf is listening on port [${staf.port}]</echo>
      </then>
      <else>
        <echo>Staf is not running</echo>
      </else>
    </if>
  </target>
 
  <!-- Display STAF gui -->
  <target name="gui">
    <exec dir="${staf.install.dir}"
          executable="${java.path}/bin/java"
          spawn="true">
      <env key="${var.path}" path="${java.path}${file.separator}bin${path.separator}${staf.install.dir}${file.separator}bin"/>
      <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
      <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}:."/>
      <env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
      <env key="STAFCODEPAGE" value="LATIN_1"/>
      <arg value="-classpath"/>
      <arg value="${staf.install.dir}/services/stax/STAXMon.jar${path.separator}${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}"
          executable="${java.path}/bin/java"
          spawn="true">
      <env key="${var.path}" path="${java.path}${file.separator}bin${path.separator}${staf.install.dir}${file.separator}bin"/>
      <env key="LD_LIBRARY_PATH" path="${staf.lib.dir}"/>
      <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}:."/>
      <env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
      <env key="STAFCODEPAGE" value="LATIN_1"/>
      <arg value="-classpath"/>
      <arg value="${staf.lib.dir}${path.separator}${staf.lib.dir}/JSTAF.jar"/>
      <arg value="com.ibm.staf.STAFJVMLogViewer"/>
    </exec>
  </target>
</project>