From 5a045e395a4da1f65091171ea5327226c81d36cd Mon Sep 17 00:00:00 2001 From: wieso-itzi Date: Wed, 13 Mar 2024 18:39:24 +0100 Subject: [PATCH 1/3] restart services automatically after upgrades on debian; change syntax of chmown commands to prevent warning messages Signed-off-by: wieso-itzi --- .../opensearch-dashboards/deb/debian/postinst | 31 +++++++++----- .../opensearch/deb/debian/postinst | 41 ++++++++++++------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst index 6f3034cbd4..ee936ac3e6 100755 --- a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst @@ -29,23 +29,32 @@ 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" +# Restart the service after an upgrade +if [ "$1" == "configure" ] && [ "$2" != "" ]; then + if command -v systemctl >/dev/null && systemctl is-enabled opensearch-dashboards.service >/dev/null; then + echo "Restarting opensearch-dashboards.service after upgrade" + systemctl start opensearch-dashboards.service + fi +else + # 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" +fi + 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} +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/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/opensearch/deb/debian/postinst index aa1fe82319..2a6837fb8f 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch/deb/debian/postinst @@ -37,11 +37,11 @@ if ! grep -q '## OpenSearch Performance Analyzer' ${config_dir}/jvm.options; the 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} +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 @@ -57,17 +57,30 @@ 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" +# Restart the services after an upgrade +if [ "$1" == "configure" ] && [ "$2" != "" ]; then + if command -v systemctl >/dev/null && systemctl is-enabled opensearch.service >/dev/null; then + echo "Restarting opensearch.service after upgrade" + systemctl start opensearch.service + fi + if command -v systemctl >/dev/null && systemctl is-enabled opensearch-performance-analyzer.service >/dev/null; then + echo "Restarting opensearch-performance-analyzer.service after upgrade" + systemctl start opensearch-performance-analyzer.service + fi +else + # 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" + 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 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" From 88d5d7261921f5fe067fbe0de1d217db5e24c143 Mon Sep 17 00:00:00 2001 From: wieso-itzi Date: Thu, 14 Mar 2024 07:27:30 +0100 Subject: [PATCH 2/3] use '=' instead of '==' as equality operator to comply with POSIX and use '-n' to check if a variable is unequal to an empty string Signed-off-by: wieso-itzi --- .../build_templates/opensearch-dashboards/deb/debian/postinst | 2 +- scripts/pkg/build_templates/opensearch/deb/debian/postinst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst index ee936ac3e6..b236da178f 100755 --- a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst @@ -30,7 +30,7 @@ if command -v systemd-tmpfiles > /dev/null; then fi # Restart the service after an upgrade -if [ "$1" == "configure" ] && [ "$2" != "" ]; then +if [ "$1" = "configure" ] && [ -n "$2" ]; then if command -v systemctl >/dev/null && systemctl is-enabled opensearch-dashboards.service >/dev/null; then echo "Restarting opensearch-dashboards.service after upgrade" systemctl start opensearch-dashboards.service diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/opensearch/deb/debian/postinst index 2a6837fb8f..8fe77aa19e 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch/deb/debian/postinst @@ -58,7 +58,7 @@ if command -v systemd-tmpfiles > /dev/null; then fi # Restart the services after an upgrade -if [ "$1" == "configure" ] && [ "$2" != "" ]; then +if [ "$1" = "configure" ] && [ -n "$2" ]; then if command -v systemctl >/dev/null && systemctl is-enabled opensearch.service >/dev/null; then echo "Restarting opensearch.service after upgrade" systemctl start opensearch.service From ed2d7e3f14a474be5fc01656cd7e627f92927848 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 15 Mar 2024 18:00:43 -0400 Subject: [PATCH 3/3] Move changes from legacy to current Signed-off-by: Peter Zhu --- .../opensearch-dashboards/deb/debian/postinst | 21 +++++++--- .../current/opensearch/deb/debian/postinst | 33 ++++++++++----- .../opensearch-dashboards/deb/debian/postinst | 31 +++++--------- .../legacy/opensearch/deb/debian/postinst | 41 +++++++------------ 4 files changed, 63 insertions(+), 63 deletions(-) diff --git a/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst index 294f284582..17356af06c 100755 --- a/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst +++ b/scripts/pkg/build_templates/current/opensearch-dashboards/deb/debian/postinst @@ -29,12 +29,21 @@ 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" +# Restart the service after an upgrade +if [ "$1" = "configure" ] && [ -n "$2" ]; then + if command -v systemctl >/dev/null && systemctl is-enabled opensearch-dashboards.service >/dev/null; then + echo "Restarting opensearch-dashboards.service after upgrade" + systemctl start opensearch-dashboards.service + fi +else + # 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" +fi + 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" diff --git a/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst index 1483395163..cf1dab2b36 100755 --- a/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst +++ b/scripts/pkg/build_templates/current/opensearch/deb/debian/postinst @@ -63,17 +63,30 @@ 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" +# Restart the services after an upgrade +if [ "$1" = "configure" ] && [ -n "$2" ]; then + if command -v systemctl >/dev/null && systemctl is-enabled opensearch.service >/dev/null; then + echo "Restarting opensearch.service after upgrade" + systemctl start opensearch.service + fi + if command -v systemctl >/dev/null && systemctl is-enabled opensearch-performance-analyzer.service >/dev/null; then + echo "Restarting opensearch-performance-analyzer.service after upgrade" + systemctl start opensearch-performance-analyzer.service + fi +else + # 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 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" diff --git a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst index b236da178f..6f3034cbd4 100755 --- a/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst +++ b/scripts/pkg/build_templates/legacy/opensearch-dashboards/deb/debian/postinst @@ -29,32 +29,23 @@ if command -v systemd-tmpfiles > /dev/null; then systemd-tmpfiles --create opensearch-dashboards.conf fi -# Restart the service after an upgrade -if [ "$1" = "configure" ] && [ -n "$2" ]; then - if command -v systemctl >/dev/null && systemctl is-enabled opensearch-dashboards.service >/dev/null; then - echo "Restarting opensearch-dashboards.service after upgrade" - systemctl start opensearch-dashboards.service - fi -else - # 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" -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} +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/deb/debian/postinst b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst index d14cf9f695..515a0e5419 100755 --- a/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst +++ b/scripts/pkg/build_templates/legacy/opensearch/deb/debian/postinst @@ -38,11 +38,11 @@ if ! grep -q '## OpenSearch Performance Analyzer' ${config_dir}/jvm.options; the 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} +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 @@ -58,30 +58,17 @@ if command -v systemd-tmpfiles > /dev/null; then systemd-tmpfiles --create opensearch.conf fi -# Restart the services after an upgrade -if [ "$1" = "configure" ] && [ -n "$2" ]; then - if command -v systemctl >/dev/null && systemctl is-enabled opensearch.service >/dev/null; then - echo "Restarting opensearch.service after upgrade" - systemctl start opensearch.service - fi - if command -v systemctl >/dev/null && systemctl is-enabled opensearch-performance-analyzer.service >/dev/null; then - echo "Restarting opensearch-performance-analyzer.service after upgrade" - systemctl start opensearch-performance-analyzer.service - fi -else - # 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" +# 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 +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"