-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RPM M1] Add rpm assemble/bundle code for opensearch using rpmbuild (#…
…1726) * Add initial rpm extraction code for core Signed-off-by: Peter Zhu <[email protected]> * Add rpm assemble/bundle code for opensearch using rpmbuild Signed-off-by: Peter Zhu <[email protected]> * Remove extra lines Signed-off-by: Peter Zhu <[email protected]> * push changes so double quotes changed to single quotes for simple strings Signed-off-by: Peter Zhu <[email protected]> * Fix scripts using the same block multiple times Signed-off-by: Peter Zhu <[email protected]> * Update all the tests and resolve checks Signed-off-by: Peter Zhu <[email protected]> * Add notes to the README file of assemble Signed-off-by: Peter Zhu <[email protected]> * Tweak rpm spec file to based on Spot comments Signed-off-by: Peter Zhu <[email protected]> * Remove extra space Signed-off-by: Peter Zhu <[email protected]>
- Loading branch information
1 parent
88be74b
commit d0189aa
Showing
18 changed files
with
3,089 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
scripts/pkg/build_templates/opensearch/opensearch.rpm.spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# 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 | ||
|
||
# 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} | ||
|
||
Name: opensearch | ||
Version: 1.3.0 | ||
Release: 1 | ||
License: Apache-2.0 | ||
Summary: An open source distributed and RESTful search engine | ||
URL: https://opensearch.org/ | ||
Group: Application/Internet | ||
ExclusiveArch: x86_64 | ||
#Requires: #java-11-amazon-corretto-devel | ||
AutoReqProv: no | ||
|
||
%description | ||
OpenSearch makes it easy to ingest, search, visualize, and analyze your data. | ||
For more information, see: https://opensearch.org/ | ||
|
||
%prep | ||
# No-op. We are using dir so no need to setup. | ||
|
||
%build | ||
# No-op. This is all pre-built Java. Nothing to do here. | ||
|
||
%install | ||
cd %{_topdir} && pwd | ||
# Create necessary directories | ||
mkdir -p %{buildroot}%{pid_dir} | ||
# Install directories/files | ||
cp -a etc usr var %{buildroot} | ||
chmod 0755 %{buildroot}%{product_dir}/bin/* | ||
chmod 0755 %{buildroot}%{product_dir}/plugins/opensearch-security/tools/* | ||
#rm -rf %{buildroot}%{product_dir}/jdk | ||
# Symlinks (do not symlink config dir as security demo installer has dependency, if no presense it will switch to rpm/deb mode) | ||
ln -s %{data_dir} %{buildroot}%{product_dir}/data | ||
ln -s %{log_dir} %{buildroot}%{product_dir}/logs | ||
# Performance Analyzer Settings | ||
echo 'true' > %{buildroot}%{data_dir}/rca_enabled.conf | ||
echo 'true' > %{buildroot}%{config_dir}/performance_analyzer_enabled.conf | ||
echo 'true' > %{buildroot}%{config_dir}/rca_enabled.conf | ||
# Change Permissions | ||
chmod -Rf a+rX,u+w,g-w,o-w %{buildroot}/* | ||
exit 0 | ||
|
||
%pre | ||
# 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 | ||
# 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 | ||
# Apply Security Settings | ||
sh %{product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s > %{log_dir}/install_demo_configuration.log 2>&1 | ||
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:///usr/share/opensearch/plugins/opensearch-performance-analyzer/pa_config/opensearch_security.policy" >> %{config_dir}/jvm.options | ||
fi | ||
# Reload systemctl daemon | ||
if command -v systemctl > /dev/null; then | ||
systemctl daemon-reload | ||
fi | ||
# Reload other configs | ||
sysctl -p %{_prefix}/lib/sysctl.d/%{name}.conf > /dev/null 2>&1 | ||
systemd-tmpfiles --create opensearch.conf | ||
# Messages | ||
echo "### NOT starting on installation, please execute the following statements to configure opensearch service to start automatically using systemd" | ||
echo " sudo systemctl daemon-reload" | ||
echo " sudo systemctl enable opensearch.service" | ||
echo "### You can start opensearch service by executing" | ||
echo " sudo systemctl start opensearch.service" | ||
echo "### Created opensearch demo certificates in %{config_dir}/certs" | ||
echo " See demo certs creation log in %{log_dir}/install_demo_configuration.log" | ||
exit 0 | ||
|
||
%preun | ||
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 | ||
exit 0 | ||
|
||
%files | ||
# Permissions | ||
%defattr(-, %{name}, %{name}) | ||
|
||
# Root dirs/docs/licenses | ||
%dir %{product_dir} | ||
%doc %{product_dir}/NOTICE.txt | ||
%doc %{product_dir}/README.md | ||
%license %{product_dir}/LICENSE.txt | ||
%{product_dir}/manifest.yml | ||
|
||
# Config dirs/files | ||
%dir %{config_dir} | ||
%{config_dir}/jvm.options.d | ||
%{config_dir}/opensearch-* | ||
%config(noreplace) %{config_dir}/%{name}.yml | ||
%config(noreplace) %{config_dir}/jvm.options | ||
%config(noreplace) %{config_dir}/log4j2.properties | ||
%config(noreplace) %{config_dir}/performance_analyzer_enabled.conf | ||
%config(noreplace) %{data_dir}/rca_enabled.conf | ||
%config(noreplace) %{config_dir}/rca_enabled.conf | ||
|
||
# Service files | ||
%attr(0644, root, root) %{_prefix}/lib/systemd/system/%{name}.service | ||
%attr(0644, root, root) %{_prefix}/lib/systemd/system/opensearch-performance-analyzer.service | ||
%attr(0644, root, root) %{_sysconfdir}/init.d/%{name} | ||
%attr(0644, root, root) %config(noreplace) %{_sysconfdir}/sysconfig/%{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 | ||
|
||
# Main dirs | ||
%{product_dir}/bin | ||
%{product_dir}/jdk | ||
%{product_dir}/lib | ||
%{product_dir}/modules | ||
%{product_dir}/performance-analyzer-rca | ||
%{product_dir}/plugins | ||
%{log_dir} | ||
%{pid_dir} | ||
%dir %{data_dir} | ||
|
||
# Symlinks | ||
%{product_dir}/data | ||
%{product_dir}/logs | ||
|
||
%changelog | ||
* Fri Mar 11 2022 OpenSearch Team <[email protected]> | ||
- Initial package | ||
|
27 changes: 27 additions & 0 deletions
27
...vice_templates/opensearch-dashboards/usr/lib/systemd/system/opensearch-dashboards.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 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. | ||
|
||
# Description: | ||
# Default opensearch-dashboards.service file | ||
|
||
[Unit] | ||
Description="OpenSearch Dashboards" | ||
|
||
[Service] | ||
Type=simple | ||
User=opensearch-dashboards | ||
Group=opensearch-dashboards | ||
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist. | ||
# Prefixing the path with '-' makes it try to load, but if the file doesn't | ||
# exist, it continues onward. | ||
EnvironmentFile=-/etc/default/opensearch-dashboards | ||
EnvironmentFile=-/etc/sysconfig/opensearch-dashboards | ||
ExecStart=/usr/share/opensearch-dashboards/bin/opensearch-dashboards "-c /etc/opensearch-dashboards/opensearch_dashboards.yml" | ||
Restart=always | ||
WorkingDirectory=/usr/share/opensearch-dashboards | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
53 changes: 53 additions & 0 deletions
53
scripts/pkg/service_templates/opensearch/etc/sysconfig/opensearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
################################ | ||
# OpenSearch | ||
################################ | ||
|
||
# OpenSearch home directory | ||
OPENSEARCH_HOME=/usr/share/opensearch | ||
|
||
# OpenSearch Java path | ||
#OPENSEARCH_JAVA_HOME=/usr/lib/jvm/java-11-amazon-corretto | ||
|
||
# OpenSearch configuration directory | ||
# Note: this setting will be shared with command-line tools | ||
OPENSEARCH_PATH_CONF=/etc/opensearch | ||
|
||
# OpenSearch PID directory | ||
PID_DIR=/var/run/opensearch | ||
|
||
# Additional Java OPTS | ||
#OPENSEARCH_JAVA_OPTS= | ||
|
||
# Configure restart on package upgrade (true, every other setting will lead to not restarting) | ||
#RESTART_ON_UPGRADE=true | ||
|
||
################################ | ||
# OpenSearch service | ||
################################ | ||
|
||
# The number of seconds to wait before checking if OpenSearch started successfully as a daemon process | ||
OPENSEARCH_STARTUP_SLEEP_TIME=5 | ||
|
||
# Notification for systemd | ||
OPENSEARCH_SD_NOTIFY=true | ||
|
||
################################ | ||
# System properties | ||
################################ | ||
|
||
# Specifies the maximum file descriptor number that can be opened by this process | ||
# When using Systemd, this setting is ignored and the LimitNOFILE defined in | ||
# /usr/lib/systemd/system/opensearch.service takes precedence | ||
#MAX_OPEN_FILES=65535 | ||
|
||
# The maximum number of bytes of memory that may be locked into RAM | ||
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option | ||
# in opensearch.yml. | ||
# When using systemd, LimitMEMLOCK must be set in a unit file such as | ||
# /etc/systemd/system/opensearch.service.d/override.conf. | ||
#MAX_LOCKED_MEMORY=unlimited | ||
|
||
# Maximum number of VMA (Virtual Memory Areas) a process can own | ||
# When using Systemd, this setting is ignored and the 'vm.max_map_count' | ||
# property is set at boot time in /usr/lib/sysctl.d/opensearch.conf | ||
#MAX_MAP_COUNT=262144 |
16 changes: 16 additions & 0 deletions
16
...rvice_templates/opensearch/usr/lib/systemd/system/opensearch-performance-analyzer.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=OpenSearch Performance Analyzer | ||
#PartOf=opensearch.service | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/share/opensearch/bin/performance-analyzer-agent-cli | ||
Restart=on-failure | ||
User=opensearch | ||
Group=opensearch | ||
Environment=OPENSEARCH_HOME=/usr/share/opensearch | ||
WorkingDirectory=/usr/share/opensearch | ||
|
||
[Install] | ||
#WantedBy=opensearch.service | ||
WantedBy=multi-user.target |
Oops, something went wrong.