Skip to content

Commit

Permalink
Update pre and post inst scripts for deb and rpm to store and restore…
Browse files Browse the repository at this point in the history
… service status
  • Loading branch information
QU3B1M committed Oct 24, 2024
1 parent d1cc4c9 commit 6dc22c9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
13 changes: 10 additions & 3 deletions distribution/packages/src/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data_dir=/var/lib/wazuh-indexer
log_dir=/var/log/wazuh-indexer
pid_dir=/run/wazuh-indexer
tmp_dir=/var/log/wazuh-indexer/tmp

restart_service=/tmp/wazuh-indexer.restart

# Create needed directories
mkdir -p ${tmp_dir}
Expand All @@ -46,6 +46,15 @@ if command -v systemd-tmpfiles > /dev/null; then
systemd-tmpfiles --create wazuh-indexer.conf
fi

if [ -f $restart_service ]; then
rm -f $restart_service
echo "Restarting wazuh-indexer service..."
if command -v systemctl > /dev/null; then
systemctl restart wazuh-indexer.service > /dev/null 2>&1
fi
exit 0
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"
Expand All @@ -54,5 +63,3 @@ echo "### You can start wazuh-indexer service by executing"
echo " sudo systemctl start wazuh-indexer.service"

exit 0


4 changes: 4 additions & 0 deletions distribution/packages/src/deb/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ set -e

echo "Running Wazuh Indexer Pre-Installation Script"

# Reference to restore actual service status
restart_service=/tmp/wazuh-indexer.restart

# Stop existing service
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer.service >/dev/null; then
echo "Stop existing wazuh-indexer.service"
systemctl --no-reload stop wazuh-indexer.service
touch $restart_service
fi
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer-performance-analyzer.service >/dev/null; then
echo "Stop existing wazuh-indexer-performance-analyzer.service"
Expand Down
10 changes: 10 additions & 0 deletions distribution/packages/src/rpm/wazuh-indexer.rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ set -e
if command -v systemctl >/dev/null && systemctl is-active %{name}.service >/dev/null; then
echo "Stop existing %{name}.service"
systemctl --no-reload stop %{name}.service
touch %{tmp_dir}/wazuh-indexer.restart
fi
if command -v systemctl >/dev/null && systemctl is-active %{name}-performance-analyzer.service >/dev/null; then
echo "Stop existing %{name}-performance-analyzer.service"
Expand Down Expand Up @@ -204,6 +205,15 @@ if command -v systemd-tmpfiles > /dev/null; then
systemd-tmpfiles --create %{name}.conf
fi

if [ -f %{tmp_dir}/wazuh-indexer.restart ]; then
rm -f %{tmp_dir}/wazuh-indexer.restart
if command -v systemctl > /dev/null; then
echo "Restarting wazuh-indexer service..."
systemctl restart wazuh-server.service > /dev/null 2>&1
exit 0
fi
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"
Expand Down

0 comments on commit 6dc22c9

Please sign in to comment.