Skip to content

Commit

Permalink
More changes to compatibility with sysv
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasas993 committed Nov 15, 2024
1 parent 7dd86ad commit 8f97e4d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
13 changes: 8 additions & 5 deletions distribution/packages/src/common/scripts/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions distribution/packages/src/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8f97e4d

Please sign in to comment.