17
17
%define _source_filedigest_algorithm 8
18
18
%define _binary_filedigest_algorithm 8
19
19
20
- # Fixed in Fedora:
20
+ # Fixed in Fedora:
21
21
# https://www.endpointdev.com/blog/2011/10/rpm-building-fedoras-sharedstatedir/
22
22
%define _sharedstatedir /var/lib
23
23
@@ -43,32 +43,36 @@ ExclusiveArch: %{_architecture}
43
43
AutoReqProv: no
44
44
45
45
%description
46
- Wazuh indexer is a near real-time full-text search and analytics engine that
47
- gathers security-related data into one platform. This Wazuh central component
48
- indexes and stores alerts generated by the Wazuh server. Wazuh indexer can be
49
- configured as a single-node or multi-node cluster, providing scalability and
46
+ Wazuh indexer is a near real-time full-text search and analytics engine that
47
+ gathers security-related data into one platform. This Wazuh central component
48
+ indexes and stores alerts generated by the Wazuh server. Wazuh indexer can be
49
+ configured as a single-node or multi-node cluster, providing scalability and
50
50
high availability.
51
51
For more information, see: https://www.wazuh.com/
52
52
53
53
%prep
54
54
# No-op. We are using dir so no need to setup.
55
55
56
56
%build
57
- # No-op. This is all pre-built Java. Nothing to do here.
57
+
58
+ %define observability_plugin %( if [ -f %{_topdir }/etc/wazuh-indexer/opensearch-observability/observability.yml ]; then echo "1" ; else echo "0"; fi )
59
+ %define reportsscheduler_plugin %( if [ -f %{_topdir }/etc/wazuh-indexer/opensearch-reports-scheduler/reports-scheduler.yml ]; then echo "1" ; else echo "0"; fi )
58
60
59
61
%install
60
62
set -e
61
63
cd %{_topdir } && pwd
64
+
62
65
# Create necessary directories
63
66
mkdir -p %{buildroot }%{pid_dir }
64
67
mkdir -p %{buildroot }%{product_dir }/plugins
68
+
65
69
# Install directories/files
66
70
cp -a etc usr var %{buildroot }
67
- chmod 0750 %{buildroot }%{product_dir }/bin/*
71
+ chmod 0755 %{buildroot }%{product_dir }/bin/*
68
72
if [ -d %{buildroot }%{product_dir }/plugins/opensearch-security ]; then
69
- chmod 0640 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/*
70
- chmod 0740 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/* .sh
73
+ chmod 0755 %{buildroot }%{product_dir }/plugins/opensearch-security/tools/*
71
74
fi
75
+
72
76
# Pre-populate the folders to ensure rpm build success even without all plugins
73
77
mkdir -p %{buildroot }%{config_dir }/opensearch-observability
74
78
mkdir -p %{buildroot }%{config_dir }/opensearch-reports-scheduler
81
85
if [ ! -f %{buildroot }%{data_dir }/performance_analyzer_enabled.conf ]; then
82
86
echo 'true' > %{buildroot }%{data_dir }/performance_analyzer_enabled.conf
83
87
fi
88
+
89
+ # Build a filelist to be included in the %files section
90
+ echo '%defattr (640, %{name }, %{name }, 750)' > filelist.txt
91
+ find %{buildroot } -type d >> filelist.txt
92
+ sed -i 's|%{buildroot }|%%dir |' filelist.txt
93
+ find %{buildroot } -type f >> filelist.txt
94
+ sed -i 's|%{buildroot }|| ' filelist.txt
95
+
96
+ # The %install section gets executed under a dash shell,
97
+ # which doesn't have array structures.
98
+ # Below, we are building a list of directories
99
+ # which will later be excluded from filelist.txt
100
+ set -- "%%dir %{_sysconfdir }"
101
+ set -- "$@" "%%dir %{_sysconfdir }/sysconfig"
102
+ set -- "$@" "%%dir %{_sysconfdir }/init.d"
103
+ set -- "$@" "%%dir /usr"
104
+ set -- "$@" "%%dir /usr/lib"
105
+ set -- "$@" "%%dir /usr/lib/systemd/system"
106
+ set -- "$@" "%%dir /usr/lib/tmpfiles.d"
107
+ set -- "$@" "%%dir /usr/share"
108
+ set -- "$@" "%%dir /var"
109
+ set -- "$@" "%%dir /var/lib"
110
+ set -- "$@" "%%dir /var/log"
111
+ set -- "$@" "%%dir /usr/lib/sysctl.d"
112
+ set -- "$@" "%%dir /usr/lib/systemd"
113
+ set -- "$@" "%%dir /usr/lib/systemd"
114
+ set -- "$@" "%{_sysconfdir }/sysconfig/%{name }"
115
+ set -- "$@" "%{config_dir }/log4j2.properties"
116
+ set -- "$@" "%{config_dir }/jvm.options"
117
+ set -- "$@" "%{config_dir }/opensearch.yml"
118
+ set -- "$@" "%{config_dir }/wazuh-template.json"
119
+ set -- "$@" "%{product_dir }/VERSION"
120
+ set -- "$@" "%{product_dir }/plugins/opensearch-security/tools/.*\.sh"
121
+ set -- "$@" "%{product_dir }/bin/.*"
122
+ set -- "$@" "%{product_dir }/jdk/bin/.*"
123
+ set -- "$@" "%{product_dir }/jdk/lib/jspawnhelper"
124
+ set -- "$@" "%{product_dir }/jdk/lib/modules"
125
+ set -- "$@" "%{product_dir }/performance-analyzer-rca/bin/.*"
126
+ set -- "$@" "%{product_dir }/NOTICE.txt"
127
+ set -- "$@" "%{product_dir }/README.md"
128
+ set -- "$@" "%{product_dir }/LICENSE.txt"
129
+ set -- "$@" "%{_prefix }/lib/systemd/system/%{name }.service"
130
+ set -- "$@" "%{_prefix }/lib/systemd/system/%{name }-performance-analyzer.service"
131
+ set -- "$@" "%{_sysconfdir }/init.d/%{name }"
132
+ set -- "$@" "%{_sysconfdir }/sysconfig/%{name }"
133
+ set -- "$@" "%{_prefix }/lib/sysctl.d/%{name }.conf"
134
+ set -- "$@" "%{_prefix }/lib/tmpfiles.d/%{name }.conf"
135
+ set -- "$@" "%%dir %{product_dir }/bin/opensearch-performance-analyzer"
136
+
137
+ # Check if we are including the observability and reports scheduler
138
+ # plugins
139
+ if [ %observability_plugin -eq 1 ]; then
140
+ set -- "$@" "%{config_dir }/opensearch-observability/observability.yml"
141
+ fi
142
+
143
+ if [ %reportsscheduler_plugin -eq 1 ]; then
144
+ set -- "$@" "%{config_dir }/opensearch-reports-scheduler/reports-scheduler.yml"
145
+ fi
146
+
147
+ for i in "$@"
148
+ do
149
+ sed -ri "\|^$i$|d" filelist.txt
150
+ done
151
+
84
152
# Change Permissions
85
153
chmod -Rf a+rX,u+w,g-w,o-w %{buildroot }/*
86
154
exit 0
@@ -107,6 +175,7 @@ exit 0
107
175
set -e
108
176
chown -R %{name }.%{name } %{config_dir }
109
177
chown -R %{name }.%{name } %{log_dir }
178
+
110
179
# Apply PerformanceAnalyzer Settings
111
180
chmod a+rw /tmp
112
181
if ! grep -q '## OpenSearch Performance Analyzer' %{config_dir}/jvm.options; then
@@ -152,47 +221,45 @@ if command -v systemctl >/dev/null && systemctl is-active %{name}-performance-an
152
221
fi
153
222
exit 0
154
223
155
- %files
156
- # Permissions
157
- %defattr(-, %{name}, %{name})
224
+ %files -f %{_topdir }/filelist.txt
225
+ %defattr(640, %{name}, %{name}, 750)
158
226
159
- # Root dirs/docs/licenses
160
- %dir %{product_dir }
161
227
%doc %{product_dir }/NOTICE.txt
162
228
%doc %{product_dir }/README.md
163
229
%license %{product_dir }/LICENSE.txt
164
230
165
- # Config dirs/files
166
- %dir %{config_dir }
167
- %{config_dir }/jvm.options.d
168
- %{config_dir }/opensearch-*
169
- %config(noreplace) %{config_dir }/opensearch.yml
170
- %config(noreplace) %{config_dir }/jvm.options
171
- %config(noreplace) %{config_dir }/log4j2.properties
172
- %config(noreplace) %{data_dir }/rca_enabled.conf
173
- %config(noreplace) %{data_dir }/performance_analyzer_enabled.conf
174
-
175
231
# Service files
176
232
%attr(0644, root, root) %{_prefix }/lib/systemd/system/%{name }.service
177
233
%attr(0644, root, root) %{_prefix }/lib/systemd/system/%{name }-performance-analyzer.service
178
234
%attr(0644, root, root) %{_sysconfdir }/init.d/%{name }
179
- %attr(0644, root, root) %config(noreplace) %{_sysconfdir }/sysconfig/%{name }
180
235
%attr(0644, root, root) %config(noreplace) %{_prefix }/lib/sysctl.d/%{name }.conf
181
236
%attr(0644, root, root) %config(noreplace) %{_prefix }/lib/tmpfiles.d/%{name }.conf
182
237
183
- # Main dirs
184
- %{product_dir }/bin
185
- %{product_dir }/jdk
186
- %{product_dir }/lib
187
- %{product_dir }/modules
188
- %{product_dir }/performance-analyzer-rca
189
- %{product_dir }/plugins
190
- %{log_dir }
191
- %{pid_dir }
192
- %dir %{data_dir }
193
-
194
- # Wazuh additional files
238
+
239
+ # Configuration files
240
+ %config(noreplace) %attr(0660, root, %{name}) "%{_sysconfdir }/sysconfig/%{name }"
241
+ %config(noreplace) %attr(660, %{name}, %{name}) %{config_dir }/log4j2.properties
242
+ %config(noreplace) %attr(660, %{name}, %{name}) %{config_dir }/jvm.options
243
+ %config(noreplace) %attr(660, %{name}, %{name}) %{config_dir }/opensearch.yml
244
+
245
+
246
+ %if %observability_plugin
247
+ %config(noreplace) %attr(660, %{name}, %{name}) %{config_dir }/opensearch-observability/observability.yml
248
+ %endif
249
+
250
+ %if %reportsscheduler_plugin
251
+ %config(noreplace) %attr(660, %{name}, %{name}) %{config_dir }/opensearch-reports-scheduler/reports-scheduler.yml
252
+ %endif
253
+
254
+
255
+ # Files that need other permissions
195
256
%attr(440, %{name}, %{name}) %{product_dir }/VERSION
257
+ %attr(740, %{name}, %{name}) %{product_dir }/plugins/opensearch-security/tools/*.sh
258
+ %attr(750, %{name}, %{name}) %{product_dir }/bin/*
259
+ %attr(750, %{name}, %{name}) %{product_dir }/jdk/bin/*
260
+ %attr(750, %{name}, %{name}) %{product_dir }/jdk/lib/jspawnhelper
261
+ %attr(750, %{name}, %{name}) %{product_dir }/jdk/lib/modules
262
+ %attr(750, %{name}, %{name}) %{product_dir }/performance-analyzer-rca/bin/*
196
263
%attr(660, %{name}, %{name}) %{config_dir }/wazuh-template.json
197
264
198
265
%changelog
0 commit comments