diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst index 6f3034cbd4..c2cea9559c 100755 --- a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/postinst @@ -20,12 +20,12 @@ log_dir=/var/log/opensearch-dashboards pid_dir=/var/run/opensearch-dashboards # Reload systemctl daemon -if command -v systemctl > /dev/null; then +if [ -d /run/systemd/system ]; then systemctl daemon-reload fi # Reload other configs -if command -v systemd-tmpfiles > /dev/null; then +if [ -d /run/systemd/system ]; then systemd-tmpfiles --create opensearch-dashboards.conf fi diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst index 3769b373aa..4109eef495 100755 --- a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst +++ b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/preinst @@ -14,7 +14,7 @@ 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 +if [ -d /run/systemd/system ] && systemctl is-active opensearch-dashboards.service >/dev/null; then echo "Stop existing opensearch-dashboards.service" systemctl --no-reload stop opensearch-dashboards.service fi diff --git a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm index 64df589312..aacc1bc04c 100755 --- a/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm +++ b/scripts/pkg/build_templates/opensearch-dashboards/deb/debian/prerm @@ -14,7 +14,7 @@ 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 +if [ -d /run/systemd/system ] >/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 diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/postinst b/scripts/pkg/build_templates/opensearch/deb/debian/postinst index 515a0e5419..3c274d87d3 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/postinst +++ b/scripts/pkg/build_templates/opensearch/deb/debian/postinst @@ -45,16 +45,16 @@ chown -R opensearch.opensearch ${data_dir} chown -R opensearch.opensearch ${pid_dir} # Reload systemctl daemon -if command -v systemctl > /dev/null; then +if [ -d /run/systemd/system ] ; then systemctl daemon-reload fi # Reload other configs -if command -v systemctl > /dev/null; then +if [ -d /run/systemd/system ] ; then systemctl restart systemd-sysctl.service || true fi -if command -v systemd-tmpfiles > /dev/null; then +if [ -d /run/systemd/system ] ; then systemd-tmpfiles --create opensearch.conf fi diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/preinst b/scripts/pkg/build_templates/opensearch/deb/debian/preinst index 1a02cc06c1..cf0b5789a9 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/preinst +++ b/scripts/pkg/build_templates/opensearch/deb/debian/preinst @@ -14,11 +14,11 @@ 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 +if [ -d /run/systemd/system ] && 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 +if [ -d /run/systemd/system ] && 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 diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/prerm b/scripts/pkg/build_templates/opensearch/deb/debian/prerm index 082ee61e6e..26bff4de44 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/prerm +++ b/scripts/pkg/build_templates/opensearch/deb/debian/prerm @@ -14,11 +14,11 @@ 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 +if [ -d /run/systemd/system ] && 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 +if [ -d /run/systemd/system ] && 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