diff --git a/distribution/packages/src/common/scripts/prerm b/distribution/packages/src/common/scripts/prerm index 7609abb950339..570e9dcb7043b 100644 --- a/distribution/packages/src/common/scripts/prerm +++ b/distribution/packages/src/common/scripts/prerm @@ -55,6 +55,9 @@ if [ "$STOP_REQUIRED" = "true" ]; then if command -v systemctl >/dev/null; then systemctl --no-reload stop wazuh-indexer.service + elif command -v service >/dev/null && service wazuh-indexer status >/dev/null 2>&1; then + service wazuh-indexer stop + elif [ -x /etc/init.d/wazuh-indexer ]; then if command -v invoke-rc.d >/dev/null; then invoke-rc.d wazuh-indexer stop @@ -81,13 +84,13 @@ fi if [ "$REMOVE_SERVICE" = "true" ]; then if command -v systemctl >/dev/null; then systemctl disable wazuh-indexer.service > /dev/null 2>&1 || true - fi - if command -v chkconfig >/dev/null; then - chkconfig --del wazuh-indexer 2> /dev/null || true - fi + # Check for SysV + elif command -v service > /dev/null 2>&1 && command -v chkconfig > /dev/null 2>&1; then + chkconfig wazuh-indexer off > /dev/null 2>&1 + chkconfig --del wazuh-indexer > /dev/null 2>&1 - if command -v update-rc.d >/dev/null; then + elif command -v update-rc.d >/dev/null; then update-rc.d wazuh-indexer remove >/dev/null || true fi fi diff --git a/distribution/packages/src/deb/debian/postinst b/distribution/packages/src/deb/debian/postinst index 964108be57bba..af3384862eabf 100644 --- a/distribution/packages/src/deb/debian/postinst +++ b/distribution/packages/src/deb/debian/postinst @@ -64,10 +64,24 @@ if [ -f $restart_service ]; then fi # Messages -echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using systemd" -echo " sudo systemctl daemon-reload" -echo " sudo systemctl enable wazuh-indexer.service" -echo "### You can start wazuh-indexer service by executing" -echo " sudo systemctl start wazuh-indexer.service" +if command -v systemctl >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using systemd" + echo " sudo systemctl daemon-reload" + echo " sudo systemctl enable wazuh-indexer.service" + echo "### You can start wazuh-indexer service by executing" + echo " sudo systemctl start wazuh-indexer.service" + +elif command -v chkconfig >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using chkconfig" + echo " sudo chkconfig --add wazuh-indexer" + echo "### You can start wazuh-indexer service by executing" + echo " sudo service wazuh-indexer start" + +elif command -v update-rc.d >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using chkconfig" + echo " sudo update-rc.d wazuh-indexer defaults 95 10" + echo "### You can start wazuh-indexer service by executing" + echo " sudo /etc/init.d/wazuh-indexer start" +fi exit 0