From cf8508d0b1317511ebfe955a044a278d569c6a36 Mon Sep 17 00:00:00 2001 From: wieso-itzi <85185077+wieso-itzi@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:45:36 +0100 Subject: [PATCH] Automatic Service Restart (Debian) (#4530) Signed-off-by: wieso-itzi Signed-off-by: Peter Zhu Co-authored-by: wieso-itzi Co-authored-by: Peter Zhu --- .../opensearch-dashboards/deb/debian/postinst | 21 ++++++++---- .../current/opensearch/deb/debian/postinst | 33 +++++++++++++------ 2 files changed, 38 insertions(+), 16 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"