forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 23
/
wazuh-indexer.rpm.spec
322 lines (284 loc) · 13.6 KB
/
wazuh-indexer.rpm.spec
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
# No build, no debuginfo
%define debug_package %{nil}
# Disable brp-java-repack-jars, so jars will not be decompressed and repackaged
%define __jar_repack 0
# Generate digests, 8 means algorithm of sha256
# This is different from rpm sig algorithm
# Requires rpm version 4.12 + to generate but b/c run on older versions
%define _source_filedigest_algorithm 8
%define _binary_filedigest_algorithm 8
# Fixed in Fedora:
# https://www.endpointdev.com/blog/2011/10/rpm-building-fedoras-sharedstatedir/
%define _sharedstatedir /var/lib
# User Define Variables
%define product_dir %{_datadir}/%{name}
%define config_dir %{_sysconfdir}/%{name}
%define data_dir %{_sharedstatedir}/%{name}
%define log_dir %{_localstatedir}/log/%{name}
%define pid_dir %{_localstatedir}/run/%{name}
%define tmp_dir %{log_dir}/tmp
%{!?_version: %define _version 0.0.0 }
%{!?_architecture: %define _architecture x86_64 }
Name: wazuh-indexer
Version: %{_version}
Release: %{_release}
License: Apache-2.0
Summary: An open source distributed and RESTful search engine
URL: https://www.wazuh.com/
Vendor: Wazuh, Inc <[email protected]>
Packager: Wazuh, Inc <[email protected]>
Group: Application/Internet
ExclusiveArch: %{_architecture}
AutoReqProv: no
%description
Wazuh indexer is a near real-time full-text search and analytics engine that
gathers security-related data into one platform. This Wazuh central component
indexes and stores alerts generated by the Wazuh server. Wazuh indexer can be
configured as a single-node or multi-node cluster, providing scalability and
high availability.
For more information, see: https://www.wazuh.com/
%prep
# No-op. We are using dir so no need to setup.
%build
%define observability_plugin %( if [ -f %{_topdir}/etc/wazuh-indexer/opensearch-observability/observability.yml ]; then echo "1" ; else echo "0"; fi )
%define reportsscheduler_plugin %( if [ -f %{_topdir}/etc/wazuh-indexer/opensearch-reports-scheduler/reports-scheduler.yml ]; then echo "1" ; else echo "0"; fi )
%install
set -e
cd %{_topdir} && pwd
# Create necessary directories
mkdir -p %{buildroot}%{pid_dir}
mkdir -p %{buildroot}%{product_dir}/plugins
mkdir -p %{buildroot}%{tmp_dir}
# Install directories/files
cp -a etc usr var %{buildroot}
chmod 0755 %{buildroot}%{product_dir}/bin/*
if [ -d %{buildroot}%{product_dir}/plugins/opensearch-security ]; then
chmod 0755 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/*
fi
# Pre-populate the folders to ensure rpm build success even without all plugins
mkdir -p %{buildroot}%{config_dir}/opensearch-observability
mkdir -p %{buildroot}%{config_dir}/opensearch-reports-scheduler
mkdir -p %{buildroot}%{product_dir}/performance-analyzer-rca
# Pre-populate PA configs if not present
if [ ! -f %{buildroot}%{data_dir}/rca_enabled.conf ]; then
echo 'true' > %{buildroot}%{data_dir}/rca_enabled.conf
fi
if [ ! -f %{buildroot}%{data_dir}/performance_analyzer_enabled.conf ]; then
echo 'true' > %{buildroot}%{data_dir}/performance_analyzer_enabled.conf
fi
# Build a filelist to be included in the %files section
echo '%defattr(640, %{name}, %{name}, 750)' > filelist.txt
find %{buildroot} -type d >> filelist.txt
sed -i 's|%{buildroot}|%%dir |' filelist.txt
find %{buildroot} -type f >> filelist.txt
sed -i 's|%{buildroot}||' filelist.txt
# The %install section gets executed under a dash shell,
# which doesn't have array structures.
# Below, we are building a list of directories
# which will later be excluded from filelist.txt
set -- "%%dir %{_sysconfdir}"
set -- "$@" "%%dir %{_sysconfdir}/sysconfig"
set -- "$@" "%%dir %{_sysconfdir}/init.d"
set -- "$@" "%%dir /usr"
set -- "$@" "%%dir /usr/lib"
set -- "$@" "%%dir /usr/lib/systemd/system"
set -- "$@" "%%dir /usr/lib/tmpfiles.d"
set -- "$@" "%%dir /usr/share"
set -- "$@" "%%dir /var"
set -- "$@" "%%dir /var/lib"
set -- "$@" "%%dir /var/log"
set -- "$@" "%%dir /usr/lib/sysctl.d"
set -- "$@" "%%dir /usr/lib/systemd"
set -- "$@" "%%dir /usr/lib/systemd"
set -- "$@" "%{_sysconfdir}/sysconfig/%{name}"
set -- "$@" "%{config_dir}/log4j2.properties"
set -- "$@" "%{config_dir}/jvm.options"
set -- "$@" "%{config_dir}/opensearch.yml"
set -- "$@" "%{product_dir}/VERSION"
set -- "$@" "%{product_dir}/plugins/opensearch-security/tools/.*\.sh"
set -- "$@" "%{product_dir}/bin/.*"
set -- "$@" "%{product_dir}/jdk/bin/.*"
set -- "$@" "%{product_dir}/jdk/lib/jspawnhelper"
set -- "$@" "%{product_dir}/jdk/lib/modules"
set -- "$@" "%{product_dir}/performance-analyzer-rca/bin/.*"
set -- "$@" "%{product_dir}/NOTICE.txt"
set -- "$@" "%{product_dir}/README.md"
set -- "$@" "%{product_dir}/LICENSE.txt"
set -- "$@" "%{_prefix}/lib/systemd/system/%{name}.service"
set -- "$@" "%{_prefix}/lib/systemd/system/%{name}-performance-analyzer.service"
set -- "$@" "%{_sysconfdir}/init.d/%{name}"
set -- "$@" "%{_sysconfdir}/sysconfig/%{name}"
set -- "$@" "%{_prefix}/lib/sysctl.d/%{name}.conf"
set -- "$@" "%{_prefix}/lib/tmpfiles.d/%{name}.conf"
set -- "$@" "%%dir %{product_dir}/bin/opensearch-performance-analyzer"
# Check if we are including the observability and reports scheduler
# plugins
if [ %observability_plugin -eq 1 ]; then
set -- "$@" "%{config_dir}/opensearch-observability/observability.yml"
fi
if [ %reportsscheduler_plugin -eq 1 ]; then
set -- "$@" "%{config_dir}/opensearch-reports-scheduler/reports-scheduler.yml"
fi
for i in "$@"
do
sed -ri "\|^$i$|d" filelist.txt
done
# Change Permissions
chmod -Rf a+rX,u+w,g-w,o-w %{buildroot}/*
exit 0
%pre
set -e
# Stop existing service
if command -v systemctl >/dev/null && systemctl is-active %{name}.service >/dev/null; then
echo "Stop existing %{name}.service"
systemctl --no-reload stop %{name}.service
fi
if command -v systemctl >/dev/null && systemctl is-active %{name}-performance-analyzer.service >/dev/null; then
echo "Stop existing %{name}-performance-analyzer.service"
systemctl --no-reload stop %{name}-performance-analyzer.service
fi
# Create user and group if they do not already exist.
getent group %{name} > /dev/null 2>&1 || groupadd -r %{name}
getent passwd %{name} > /dev/null 2>&1 || \
useradd -r -g %{name} -M -s /sbin/nologin \
-c "%{name} user/group" %{name}
exit 0
%post
set -e
chown -R %{name}.%{name} %{config_dir}
chown -R %{name}.%{name} %{log_dir}
# Apply PerformanceAnalyzer Settings
chmod a+rw /tmp
if ! grep -q '## OpenSearch Performance Analyzer' %{config_dir}/jvm.options; then
# Add Performance Analyzer settings in %{config_dir}/jvm.options
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> %{config_dir}/jvm.options
echo '## OpenSearch Performance Analyzer' >> %{config_dir}/jvm.options
echo "-Dclk.tck=$CLK_TCK" >> %{config_dir}/jvm.options
echo "-Djdk.attach.allowAttachSelf=true" >> %{config_dir}/jvm.options
echo "-Djava.security.policy=file://%{config_dir}/opensearch-performance-analyzer/opensearch_security.policy" >> %{config_dir}/jvm.options
echo "--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED" >> %{config_dir}/jvm.options
fi
# Reload systemctl daemon
if command -v systemctl > /dev/null; then
systemctl daemon-reload
fi
# Reload other configs
if command -v systemctl > /dev/null; then
systemctl restart systemd-sysctl.service || true
fi
if command -v systemd-tmpfiles > /dev/null; then
systemd-tmpfiles --create %{name}.conf
fi
# Messages
echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using systemd"
echo " sudo systemctl daemon-reload"
echo " sudo systemctl enable wazuh-indexer.service"
echo "### You can start wazuh-indexer service by executing"
echo " sudo systemctl start wazuh-indexer.service"
exit 0
%preun
set -e
if command -v systemctl >/dev/null && systemctl is-active %{name}.service >/dev/null; then
echo "Stop existing %{name}.service"
systemctl --no-reload stop %{name}.service
fi
if command -v systemctl >/dev/null && systemctl is-active %{name}-performance-analyzer.service >/dev/null; then
echo "Stop existing %{name}-performance-analyzer.service"
systemctl --no-reload stop %{name}-performance-analyzer.service
fi
exit 0
%files -f %{_topdir}/filelist.txt
%defattr(640, %{name}, %{name}, 750)
%doc %{product_dir}/NOTICE.txt
%doc %{product_dir}/README.md
%license %{product_dir}/LICENSE.txt
# Service files
%attr(0644, root, root) %{_prefix}/lib/systemd/system/%{name}.service
%attr(0644, root, root) %{_prefix}/lib/systemd/system/%{name}-performance-analyzer.service
%attr(0644, root, root) %{_sysconfdir}/init.d/%{name}
%attr(0644, root, root) %config(noreplace) %{_prefix}/lib/sysctl.d/%{name}.conf
%attr(0644, root, root) %config(noreplace) %{_prefix}/lib/tmpfiles.d/%{name}.conf
# Configuration files
%config(noreplace) %attr(0660, root, %{name}) "%{_sysconfdir}/sysconfig/%{name}"
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/log4j2.properties
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/jvm.options
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/opensearch.yml
%if %observability_plugin
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/opensearch-observability/observability.yml
%endif
%if %reportsscheduler_plugin
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/opensearch-reports-scheduler/reports-scheduler.yml
%endif
# Files that need other permissions
%attr(440, %{name}, %{name}) %{product_dir}/VERSION
%attr(740, %{name}, %{name}) %{product_dir}/plugins/opensearch-security/tools/*.sh
%attr(750, %{name}, %{name}) %{product_dir}/bin/*
%attr(750, %{name}, %{name}) %{product_dir}/jdk/bin/*
%attr(750, %{name}, %{name}) %{product_dir}/jdk/lib/jspawnhelper
%attr(750, %{name}, %{name}) %{product_dir}/jdk/lib/modules
%attr(750, %{name}, %{name}) %{product_dir}/performance-analyzer-rca/bin/*
%changelog
* Thu Mar 28 2024 support <[email protected]> - 4.9.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-9-0.html
* Tue Jan 30 2024 support <[email protected]> - 4.8.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-8-1.html
* Fri Dec 15 2023 support <[email protected]> - 4.8.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-8-0.html
* Tue Dec 05 2023 support <[email protected]> - 4.7.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-7-1.html
* Tue Nov 21 2023 support <[email protected]> - 4.7.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-7-0.html
* Tue Oct 31 2023 support <[email protected]> - 4.6.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-6-0.html
* Tue Oct 24 2023 support <[email protected]> - 4.5.4
- More info: https://documentation.wazuh.com/current/release-notes/release-4-5-4.html
* Tue Oct 10 2023 support <[email protected]> - 4.5.3
- More info: https://documentation.wazuh.com/current/release-notes/release-4-5-3.html
* Thu Aug 31 2023 support <[email protected]> - 4.5.2
- More info: https://documentation.wazuh.com/current/release-notes/release-4-5-2.html
* Thu Aug 24 2023 support <[email protected]> - 4.5.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-5.1.html
* Thu Aug 10 2023 support <[email protected]> - 4.5.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-5-0.html
* Mon Jul 10 2023 support <[email protected]> - 4.4.5
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-5.html
* Tue Jun 13 2023 support <[email protected]> - 4.4.4
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-4.html
* Thu May 25 2023 support <[email protected]> - 4.4.3
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-3.html
* Mon May 08 2023 support <[email protected]> - 4.4.2
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-2.html
* Mon Apr 17 2023 support <[email protected]> - 4.4.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-1.html
* Wed Jan 18 2023 support <[email protected]> - 4.4.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-4-0.html
* Thu Nov 10 2022 support <[email protected]> - 4.3.10
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-10.html
* Mon Oct 03 2022 support <[email protected]> - 4.3.9
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-9.html
* Mon Sep 19 2022 support <[email protected]> - 4.3.8
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-8.html
* Mon Aug 08 2022 support <[email protected]> - 4.3.7
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-7.html
* Thu Jul 07 2022 support <[email protected]> - 4.3.6
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-6.html
* Wed Jun 29 2022 support <[email protected]> - 4.3.5
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-5.html
* Tue Jun 07 2022 support <[email protected]> - 4.3.4
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-4.html
* Tue May 31 2022 support <[email protected]> - 4.3.3
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-3.html
* Mon May 30 2022 support <[email protected]> - 4.3.2
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-2.html
* Wed May 18 2022 support <[email protected]> - 4.3.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-1.html
* Thu May 05 2022 support <[email protected]> - 4.3.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-3-0.html
- Initial package