diff --git a/scripts/components/OpenSearch-Dashboards/install.sh b/scripts/components/OpenSearch-Dashboards/install.sh index ad06c91bb0..280ccea5be 100755 --- a/scripts/components/OpenSearch-Dashboards/install.sh +++ b/scripts/components/OpenSearch-Dashboards/install.sh @@ -87,7 +87,12 @@ fi if [ "$DISTRIBUTION" = "rpm" -o "$DISTRIBUTION" = "deb" ]; then cp -v ../../../config/opensearch_dashboards-$MAJOR_VERSION.x.yml "$OUTPUT/../etc/opensearch-dashboards/opensearch_dashboards.yml" cp -a ../../../scripts/pkg/service_templates/opensearch-dashboards/* "$OUTPUT/../" - cp -a ../../../scripts/pkg/build_templates/opensearch-dashboards/$DISTRIBUTION/* "$OUTPUT/../" + + if [ "$MAJOR_VERSION" = "1" ]; then + cp -a ../../../scripts/pkg/build_templates/opensearch-dashboards/$DISTRIBUTION/legacy/* "$OUTPUT/../" + else + cp -a ../../../scripts/pkg/build_templates/opensearch-dashboards/$DISTRIBUTION/current/* "$OUTPUT/../" + fi else cp -v ../../../config/opensearch_dashboards-$MAJOR_VERSION.x.yml "$OUTPUT/config/opensearch_dashboards.yml" fi diff --git a/scripts/components/OpenSearch/install.sh b/scripts/components/OpenSearch/install.sh index 7b384c939d..1cecc46141 100755 --- a/scripts/components/OpenSearch/install.sh +++ b/scripts/components/OpenSearch/install.sh @@ -79,11 +79,16 @@ echo $DIR cd $DIR ## Copy the tar installation script into the bundle +MAJOR_VERSION=`echo $VERSION | cut -d. -f1` if [ "$DISTRIBUTION" = "tar" ]; then cp -v ../../../scripts/startup/tar/linux/opensearch-tar-install.sh "$OUTPUT/" elif [ "$DISTRIBUTION" = "deb" -o "$DISTRIBUTION" = "rpm" ]; then cp -va ../../../scripts/pkg/service_templates/opensearch/* "$OUTPUT/../" - cp -va ../../../scripts/pkg/build_templates/opensearch/$DISTRIBUTION/* "$OUTPUT/../" + if [ "$MAJOR_VERSION" = "1" ]; then + cp -va ../../../scripts/pkg/build_templates/opensearch/$DISTRIBUTION/legacy/* "$OUTPUT/../" + else + cp -va ../../../scripts/pkg/build_templates/opensearch/$DISTRIBUTION/current/* "$OUTPUT/../" + fi elif [ "$DISTRIBUTION" = "zip" ] && [ "$PLATFORM" = "windows" ]; then cp -v ../../../scripts/startup/zip/windows/opensearch-windows-install.bat "$OUTPUT/" fi diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/Makefile b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/Makefile similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/Makefile rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/Makefile diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/control b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/control similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/control rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/control diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/copyright b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/copyright similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/copyright rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/copyright diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/preinst similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/preinst diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/prerm similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/prerm diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/rules b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/rules similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debian/rules rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/rules diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh rename to scripts/pkg/build_templates/current/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh diff --git a/scripts/pkg/build_templates/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec b/scripts/pkg/build_templates/current/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec similarity index 100% rename from scripts/pkg/build_templates/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec rename to scripts/pkg/build_templates/current/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec diff --git a/scripts/pkg/build_templates/opensearch/deb/Makefile b/scripts/pkg/build_templates/current/opensearch/deb/Makefile similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/Makefile rename to scripts/pkg/build_templates/current/opensearch/deb/Makefile diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/control b/scripts/pkg/build_templates/current/opensearch/deb/debian/control similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/control rename to scripts/pkg/build_templates/current/opensearch/deb/debian/control diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/copyright b/scripts/pkg/build_templates/current/opensearch/deb/debian/copyright similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/copyright rename to scripts/pkg/build_templates/current/opensearch/deb/debian/copyright diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/postinst rename to scripts/pkg/build_templates/current/opensearch/deb/debian/postinst diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/preinst b/scripts/pkg/build_templates/current/opensearch/deb/debian/preinst similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/preinst rename to scripts/pkg/build_templates/current/opensearch/deb/debian/preinst diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/prerm b/scripts/pkg/build_templates/current/opensearch/deb/debian/prerm similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/prerm rename to scripts/pkg/build_templates/current/opensearch/deb/debian/prerm diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/rules b/scripts/pkg/build_templates/current/opensearch/deb/debian/rules similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debian/rules rename to scripts/pkg/build_templates/current/opensearch/deb/debian/rules diff --git a/scripts/pkg/build_templates/opensearch/deb/debmake_opensearch_install.sh b/scripts/pkg/build_templates/current/opensearch/deb/debmake_opensearch_install.sh similarity index 100% rename from scripts/pkg/build_templates/opensearch/deb/debmake_opensearch_install.sh rename to scripts/pkg/build_templates/current/opensearch/deb/debmake_opensearch_install.sh diff --git a/scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec b/scripts/pkg/build_templates/current/opensearch/rpm/opensearch.rpm.spec similarity index 100% rename from scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec rename to scripts/pkg/build_templates/current/opensearch/rpm/opensearch.rpm.spec diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/Makefile b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/Makefile new file mode 100644 index 0000000000..fa1bd472f5 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/Makefile @@ -0,0 +1,19 @@ +# 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. + +# deb opensearch-dashboards Makefile + +all: install + +install: + ./debmake_opensearch_dashboards_install.sh $(CURDIR) + +clean: ; + +distclean: clean + +.PHONY: all clean distclean install diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/control b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/control new file mode 100644 index 0000000000..84c653206c --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/control @@ -0,0 +1,20 @@ +# 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. + +Source: opensearch-dashboards +Section: web +Priority: optional +Maintainer: OpenSearch Team +Build-Depends: debhelper-compat (= 12) +Standards-Version: 4.5.0 +Homepage: https://opensearch.org/ + +Package: opensearch-dashboards +Architecture: any +Description: Open source visualization dashboards for OpenSearch + OpenSearch Dashboards is the visualization tool for data in OpenSearch + For more information, see: https://opensearch.org/ diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/copyright b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/copyright new file mode 100644 index 0000000000..4b4be55590 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/copyright @@ -0,0 +1,38 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: opensearch-dashboards +Upstream-Contact: opensearch@amazon.com +Source: https://opensearch.org +Files: * +Copyright: OpenSearch Contributors +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache License, Version 2 + can be found in "/usr/share/common-licenses/Apache-2.0". + +Files: debian/* +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache License, Version 2 + can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst new file mode 100755 index 0000000000..6f3034cbd4 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst @@ -0,0 +1,52 @@ +#!/bin/bash + +# 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. + +# deb opensearch-dashboards postinst script + +set -e + +echo "Running OpenSearch-Dashboards Post-Installation Script" + +product_dir=/usr/share/opensearch-dashboards +config_dir=/etc/opensearch-dashboards +data_dir=/var/lib/opensearch-dashboards +log_dir=/var/log/opensearch-dashboards +pid_dir=/var/run/opensearch-dashboards + +# Reload systemctl daemon +if command -v systemctl > /dev/null; then + systemctl daemon-reload +fi + +# Reload other configs +if command -v systemd-tmpfiles > /dev/null; then + systemd-tmpfiles --create opensearch-dashboards.conf +fi + +# Messages +echo "### NOT starting on installation, please execute the following statements to configure opensearch-dashboards service to start automatically using systemd" +echo " sudo systemctl daemon-reload" +echo " sudo systemctl enable opensearch-dashboards.service" +echo "### You can start opensearch-dashboards service by executing" +echo " sudo systemctl start opensearch-dashboards.service" +echo "### Upcoming breaking change in packaging" +echo " In a future release of OpenSearch Dashboards, we plan to change the permissions associated with access to installed files" +echo " If you are configuring tools that require read access to the OpenSearch Dashboards configuration files, we recommend you add the user that runs these tools to the 'opensearch-dashboards' group" +echo " For more information, see https://github.com/opensearch-project/opensearch-build/pull/4043" + +# Set owner +chown -R opensearch-dashboards.opensearch-dashboards ${product_dir} +chown -R opensearch-dashboards.opensearch-dashboards ${config_dir} +chown -R opensearch-dashboards.opensearch-dashboards ${log_dir} +chown -R opensearch-dashboards.opensearch-dashboards ${data_dir} +chown -R opensearch-dashboards.opensearch-dashboards ${pid_dir} + +exit 0 + + diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/preinst b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/preinst new file mode 100755 index 0000000000..3769b373aa --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/preinst @@ -0,0 +1,27 @@ +#!/bin/bash + +# 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. + +# deb opensearch-dashboards preinst script + +set -e + +echo "Running OpenSearch-Dashboards Pre-Installation Script" + +# Stop existing service +if command -v systemctl >/dev/null && systemctl is-active opensearch-dashboards.service >/dev/null; then + echo "Stop existing opensearch-dashboards.service" + systemctl --no-reload stop opensearch-dashboards.service +fi + +# Create user and group if they do not already exist. +getent group opensearch-dashboards > /dev/null 2>&1 || groupadd -r opensearch-dashboards +getent passwd opensearch-dashboards > /dev/null 2>&1 || \ + useradd -r -g opensearch-dashboards -M -s /sbin/nologin \ + -c "opensearch-dashboards user/group" opensearch-dashboards +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/prerm b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/prerm new file mode 100755 index 0000000000..64df589312 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/prerm @@ -0,0 +1,22 @@ +#!/bin/bash + +# 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. + +# deb opensearch-dashboards prerm script + +set -e + +echo "Running OpenSearch-Dashboards Pre-Removal Script" + +# Stop existing service +if command -v systemctl >/dev/null && systemctl is-active opensearch-dashboards.service >/dev/null; then + echo "Stop existing opensearch-dashboards.service" + systemctl --no-reload stop opensearch-dashboards.service +fi + +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/rules b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/rules new file mode 100755 index 0000000000..1e13c8d707 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/rules @@ -0,0 +1,29 @@ +#!/usr/bin/make -f + +# 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. + +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ + +override_dh_builddeb: + dh_builddeb -- -Zgzip + +override_dh_gencontrol: + dh_gencontrol -- -DLicense=Apache-2.0 + +#override_dh_auto_install: +# dh_auto_install -- prefix=/usr + +#override_dh_install: +# dh_install --list-missing -X.pyc -X.pyo diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh new file mode 100755 index 0000000000..1c4f593a53 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debmake_opensearch_dashboards_install.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# 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. + +# debmake opensearch-dashboards install script + +set -ex + +if [ -z "$1" ]; then + echo "Missing curdir path" + exit 1 +fi + +curdir=$1 +product_dir=/usr/share/opensearch-dashboards +config_dir=/etc/opensearch-dashboards +data_dir=/var/lib/opensearch-dashboards +log_dir=/var/log/opensearch-dashboards +pid_dir=/var/run/opensearch-dashboards +buildroot=${curdir}/debian/opensearch-dashboards + +# Create necessary directories +mkdir -p ${buildroot} +mkdir -p ${buildroot}${pid_dir} +mkdir -p ${buildroot}${product_dir}/assets +mkdir -p ${buildroot}${product_dir}/plugins +mkdir -p ${buildroot}${log_dir} + +# Install directories/files +# Service files stored in /usr/lib/systemd for pkg installation, /etc/systemd is meant for manual changes by sysadmin +rm -rvf ${curdir}/etc/systemd +cp -a ${curdir}/etc ${curdir}/usr ${curdir}/var ${buildroot}/ +chmod -c 0755 ${buildroot}${product_dir}/bin/* + +# 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 + +# Change Permissions +chmod -Rf a+rX,u+w,g-w,o-w ${buildroot}/* + +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec b/scripts/pkg/build_templates/legacy/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec new file mode 100644 index 0000000000..6e61931e0d --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/rpm/opensearch-dashboards.rpm.spec @@ -0,0 +1,155 @@ +# 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 + +# 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} +%{!?_version: %define _version 0.0.0 } +%{!?_architecture: %define _architecture x86_64 } + +Name: opensearch-dashboards +Version: %{_version} +Release: 1 +License: Apache-2.0 +Summary: Open source visualization dashboards for OpenSearch +URL: https://opensearch.org/ +Group: Application/Internet +ExclusiveArch: %{_architecture} +AutoReqProv: no + +%description +OpenSearch Dashboards is the visualization tool for data in OpenSearch +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 +set -e +cd %{_topdir} && pwd +# Create necessary directories +mkdir -p %{buildroot}%{pid_dir} +mkdir -p %{buildroot}%{product_dir}/assets +mkdir -p %{buildroot}%{product_dir}/plugins +mkdir -p %{buildroot}%{log_dir} +# Install directories/files +# Service files stored in /usr/lib/systemd for pkg installation, /etc/systemd is meant for manual changes by sysadmin +rm -rvf etc/systemd +cp -a etc usr var %{buildroot} +chmod 0755 %{buildroot}%{product_dir}/bin/* +# 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 +# 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 +# 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 +# Reload systemctl daemon +if command -v systemctl > /dev/null; then + systemctl daemon-reload +fi +# Reload other configs +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 opensearch-dashboards service to start automatically using systemd" +echo " sudo systemctl daemon-reload" +echo " sudo systemctl enable opensearch-dashboards.service" +echo "### You can start opensearch-dashboards service by executing" +echo " sudo systemctl start opensearch-dashboards.service" +echo "### Upcoming breaking change in packaging" +echo " In a future release of OpenSearch Dashboards, we plan to change the permissions associated with access to installed files" +echo " If you are configuring tools that require read access to the OpenSearch Dashboards configuration files, we recommend you add the user that runs these tools to the 'opensearch-dashboards' group" +echo " For more information, see https://github.com/opensearch-project/opensearch-build/pull/4043" +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 +exit 0 + +%files +# Permissions +%defattr(-, %{name}, %{name}) + +# Root dirs/docs/licenses +%dir %{product_dir} +%doc %{product_dir}/NOTICE.txt +%doc %{product_dir}/README.txt +%license %{product_dir}/LICENSE.txt +%{product_dir}/package.json +%{product_dir}/manifest.yml +%{product_dir}/.i18nrc.json + +# Config dirs/files +%dir %{config_dir} +%config(noreplace) %{config_dir}/node.options +%config(noreplace) %{config_dir}/opensearch_dashboards.yml + +# Service files +%attr(0644, root, root) %{_prefix}/lib/systemd/system/%{name}.service +%attr(0644, root, root) %{_sysconfdir}/init.d/%{name} +%attr(0644, root, root) %config(noreplace) %{_sysconfdir}/default/%{name} +%attr(0644, root, root) %config(noreplace) %{_prefix}/lib/tmpfiles.d/%{name}.conf + +# Main dirs +%dir %{product_dir}/assets +%{product_dir}/bin +%{product_dir}/node +%{product_dir}/node_modules +%{product_dir}/plugins +%{product_dir}/src +%{log_dir} +%{pid_dir} +%dir %{data_dir} + +# Symlinks +%{product_dir}/data +%{product_dir}/logs + +%changelog +* Mon Mar 21 2022 OpenSearch Team +- Initial package + diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/Makefile b/scripts/pkg/build_templates/legacy/opensearch/deb/Makefile new file mode 100644 index 0000000000..766fbf0dd4 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/Makefile @@ -0,0 +1,19 @@ +# 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. + +# deb opensearch Makefile + +all: install + +install: + ./debmake_opensearch_install.sh $(CURDIR) + +clean: ; + +distclean: clean + +.PHONY: all clean distclean install diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/control b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/control new file mode 100644 index 0000000000..1f5f75624b --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/control @@ -0,0 +1,20 @@ +# 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. + +Source: opensearch +Section: web +Priority: optional +Maintainer: OpenSearch Team +Build-Depends: debhelper-compat (= 12) +Standards-Version: 4.5.0 +Homepage: https://opensearch.org/ + +Package: opensearch +Architecture: any +Description: An open source distributed and RESTful search engine + OpenSearch makes it easy to ingest, search, visualize, and analyze your data + For more information, see: https://opensearch.org/ diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/copyright b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/copyright new file mode 100644 index 0000000000..1d83d12cd8 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/copyright @@ -0,0 +1,38 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: opensearch +Upstream-Contact: opensearch@amazon.com +Source: https://opensearch.org +Files: * +Copyright: OpenSearch Contributors +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache License, Version 2 + can be found in "/usr/share/common-licenses/Apache-2.0". + +Files: debian/* +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache License, Version 2 + can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst new file mode 100755 index 0000000000..515a0e5419 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst @@ -0,0 +1,78 @@ +#!/bin/bash + +# 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. + +# deb opensearch postinst script + +set -e + +echo "Running OpenSearch Post-Installation Script" + +product_dir=/usr/share/opensearch +config_dir=/etc/opensearch +data_dir=/var/lib/opensearch +log_dir=/var/log/opensearch +pid_dir=/var/run/opensearch + +# Apply Security Settings +if [ -d ${product_dir}/plugins/opensearch-security ]; then + bash ${product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s > ${log_dir}/install_demo_configuration.log 2>&1 +fi + +# 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 + +# Set owner +chown -R opensearch.opensearch ${product_dir} +chown -R opensearch.opensearch ${config_dir} +chown -R opensearch.opensearch ${log_dir} +chown -R opensearch.opensearch ${data_dir} +chown -R opensearch.opensearch ${pid_dir} + +# 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 opensearch.conf +fi + +# 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" + +if [ -d ${product_dir}/plugins/opensearch-security ]; then + echo "### Create opensearch demo certificates in ${config_dir}/" + echo " See demo certs creation log in ${log_dir}/install_demo_configuration.log" +fi +echo "### Upcoming breaking change in packaging" +echo " In a future release of OpenSearch, we plan to change the permissions associated with access to installed files" +echo " If you are configuring tools that require read access to the OpenSearch configuration files, we recommend you add the user that runs these tools to the 'opensearch' group" +echo " For more information, see https://github.com/opensearch-project/opensearch-build/pull/4043" +exit 0 + + diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/preinst b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/preinst new file mode 100755 index 0000000000..1a02cc06c1 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/preinst @@ -0,0 +1,31 @@ +#!/bin/bash + +# 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. + +# deb opensearch preinst script + +set -e + +echo "Running OpenSearch Pre-Installation Script" + +# Stop existing service +if command -v systemctl >/dev/null && systemctl is-active opensearch.service >/dev/null; then + echo "Stop existing opensearch.service" + systemctl --no-reload stop opensearch.service +fi +if command -v systemctl >/dev/null && systemctl is-active opensearch-performance-analyzer.service >/dev/null; then + echo "Stop existing opensearch-performance-analyzer.service" + systemctl --no-reload stop opensearch-performance-analyzer.service +fi + +# Create user and group if they do not already exist. +getent group opensearch > /dev/null 2>&1 || groupadd -r opensearch +getent passwd opensearch > /dev/null 2>&1 || \ + useradd -r -g opensearch -M -s /sbin/nologin \ + -c "opensearch user/group" opensearch +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/prerm b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/prerm new file mode 100755 index 0000000000..082ee61e6e --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/prerm @@ -0,0 +1,26 @@ +#!/bin/bash + +# 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. + +# deb opensearch prerm script + +set -e + +echo "Running OpenSearch Pre-Removal Script" + +# Stop existing service +if command -v systemctl >/dev/null && systemctl is-active opensearch.service >/dev/null; then + echo "Stop existing opensearch.service" + systemctl --no-reload stop opensearch.service +fi +if command -v systemctl >/dev/null && systemctl is-active opensearch-performance-analyzer.service >/dev/null; then + echo "Stop existing opensearch-performance-analyzer.service" + systemctl --no-reload stop opensearch-performance-analyzer.service +fi + +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/rules b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/rules new file mode 100755 index 0000000000..1e13c8d707 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/rules @@ -0,0 +1,29 @@ +#!/usr/bin/make -f + +# 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. + +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ + +override_dh_builddeb: + dh_builddeb -- -Zgzip + +override_dh_gencontrol: + dh_gencontrol -- -DLicense=Apache-2.0 + +#override_dh_auto_install: +# dh_auto_install -- prefix=/usr + +#override_dh_install: +# dh_install --list-missing -X.pyc -X.pyo diff --git a/scripts/pkg/build_templates/legacy/opensearch/deb/debmake_opensearch_install.sh b/scripts/pkg/build_templates/legacy/opensearch/deb/debmake_opensearch_install.sh new file mode 100755 index 0000000000..206ca6d6d6 --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debmake_opensearch_install.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# 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. + +# debmake opensearch install script + +set -ex + +if [ -z "$1" ]; then + echo "Missing curdir path" + exit 1 +fi + +curdir=$1 +product_dir=/usr/share/opensearch +config_dir=/etc/opensearch +data_dir=/var/lib/opensearch +log_dir=/var/log/opensearch +pid_dir=/var/run/opensearch +buildroot=${curdir}/debian/opensearch + +# Create necessary directories +mkdir -p ${buildroot} +mkdir -p ${buildroot}${pid_dir} +mkdir -p ${buildroot}${product_dir}/plugins + +# Install directories/files +cp -a ${curdir}/etc ${curdir}/usr ${curdir}/var ${buildroot}/ +chmod -c 0755 ${buildroot}${product_dir}/bin/* +if [ -d ${buildroot}${product_dir}/plugins/opensearch-security ]; then + chmod -c 0755 ${buildroot}${product_dir}/plugins/opensearch-security/tools/* +fi + +# 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 + +# Change Permissions +chmod -Rf a+rX,u+w,g-w,o-w ${buildroot}/* + +exit 0 diff --git a/scripts/pkg/build_templates/legacy/opensearch/rpm/opensearch.rpm.spec b/scripts/pkg/build_templates/legacy/opensearch/rpm/opensearch.rpm.spec new file mode 100644 index 0000000000..6d9eec3bab --- /dev/null +++ b/scripts/pkg/build_templates/legacy/opensearch/rpm/opensearch.rpm.spec @@ -0,0 +1,207 @@ +# 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 + +# 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} +%{!?_version: %define _version 0.0.0 } +%{!?_architecture: %define _architecture x86_64 } + +Name: opensearch +Version: %{_version} +Release: 1 +License: Apache-2.0 +Summary: An open source distributed and RESTful search engine +URL: https://opensearch.org/ +Group: Application/Internet +ExclusiveArch: %{_architecture} +#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 +set -e +cd %{_topdir} && pwd +# Create necessary directories +mkdir -p %{buildroot}%{pid_dir} +mkdir -p %{buildroot}%{product_dir}/plugins +# 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 +#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 +# 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 +# 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 opensearch-performance-analyzer.service >/dev/null; then + echo "Stop existing opensearch-performance-analyzer.service" + systemctl --no-reload stop opensearch-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 +# Apply Security Settings +if [ -d %{product_dir}/plugins/opensearch-security ]; then + sh %{product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s > %{log_dir}/install_demo_configuration.log 2>&1 +fi +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 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" +if [ -d %{product_dir}/plugins/opensearch-security ]; then + echo "### Create opensearch demo certificates in %{config_dir}/" + echo " See demo certs creation log in %{log_dir}/install_demo_configuration.log" +fi +echo "### Upcoming breaking change in packaging" +echo " In a future release of OpenSearch, we plan to change the permissions associated with access to installed files" +echo " If you are configuring tools that require read access to the OpenSearch configuration files, we recommend you add the user that runs these tools to the 'opensearch' group" +echo " For more information, see https://github.com/opensearch-project/opensearch-build/pull/4043" +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 opensearch-performance-analyzer.service >/dev/null; then + echo "Stop existing opensearch-performance-analyzer.service" + systemctl --no-reload stop opensearch-performance-analyzer.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) %{data_dir}/rca_enabled.conf +%config(noreplace) %{data_dir}/performance_analyzer_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 +* Mon Mar 21 2022 OpenSearch Team +- Initial package +