Skip to content

Commit

Permalink
refactor: removed references to deprecated daemons in packages files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcr99 committed Aug 8, 2024
1 parent 46a77c7 commit 19fce98
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 129 deletions.
2 changes: 0 additions & 2 deletions packages/debs/SPECS/wazuh-agent/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ case "$1" in
systemctl restart wazuh-agent.service > /dev/null 2>&1
elif command -v service > /dev/null 2>&1 ; then
service wazuh-agent restart > /dev/null 2>&1
else
${DIR}/bin/wazuh-control restart > /dev/null 2>&1
fi
fi
fi
Expand Down
5 changes: 0 additions & 5 deletions packages/debs/SPECS/wazuh-agent/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ case "$1" in
elif command -v service > /dev/null 2>&1 && service wazuh-agent status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-agent stop > /dev/null 2>&1
touch ${WAZUH_TMP_DIR}/wazuh.restart
elif ${DIR}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch ${WAZUH_TMP_DIR}/wazuh.restart
elif ${DIR}/bin/ossec-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch ${WAZUH_TMP_DIR}/wazuh.restart
fi
${DIR}/bin/ossec-control stop > /dev/null 2>&1 || ${DIR}/bin/wazuh-control stop > /dev/null 2>&1

if [ -d ${DIR}/logs/ossec ]; then
mv ${DIR}/logs/ossec ${DIR}/logs/wazuh
Expand Down
51 changes: 2 additions & 49 deletions packages/debs/SPECS/wazuh-agent/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,6 @@ case "$1" in
elif command -v service > /dev/null 2>&1 && service wazuh-agent status 2>/dev/null | grep "running" > /dev/null 2>&1; then
service wazuh-agent stop > /dev/null 2>&1
fi
${DIR}/bin/wazuh-control stop > /dev/null 2>&1

# Process: wazuh-execd
if pgrep -f "wazuh-execd" > /dev/null 2>&1; then
kill -15 $(pgrep -f "wazuh-execd") > /dev/null 2>&1
fi

if pgrep -f "wazuh-execd" > /dev/null 2>&1; then
kill -9 $(pgrep -f "wazuh-execd") > /dev/null 2>&1
fi

# Process: wazuh-agentd
if pgrep -f "wazuh-agentd" > /dev/null 2>&1; then
kill -15 $(pgrep -f "wazuh-agentd") > /dev/null 2>&1
fi

if pgrep -f "wazuh-agentd" > /dev/null 2>&1; then
kill -9 $(pgrep -f "wazuh-agentd") > /dev/null 2>&1
fi

# Process: wazuh-syscheckd
if pgrep -f "wazuh-syscheckd" > /dev/null 2>&1; then
kill -15 $(pgrep -f "wazuh-syscheckd") > /dev/null 2>&1
fi

if pgrep -f "wazuh-syscheckd" > /dev/null 2>&1; then
kill -9 $(pgrep -f "wazuh-syscheckd") > /dev/null 2>&1
fi

# Process: wazuh-logcollector
if pgrep -f "wazuh-logcollector" > /dev/null 2>&1; then
kill -15 $(pgrep -f "wazuh-logcollector") > /dev/null 2>&1
fi

if pgrep -f "wazuh-logcollector" > /dev/null 2>&1; then
kill -9 $(pgrep -f "wazuh-logcollector") > /dev/null 2>&1
fi

# Process: wazuh-modulesd
if pgrep -f "wazuh-modulesd" > /dev/null 2>&1; then
kill -15 $(pgrep -f "wazuh-modulesd") > /dev/null 2>&1
fi

if pgrep -f "wazuh-modulesd" > /dev/null 2>&1; then
kill -9 $(pgrep -f "wazuh-modulesd") > /dev/null 2>&1
fi

;;

Expand All @@ -73,7 +27,6 @@ case "$1" in
elif command -v service > /dev/null 2>&1 && service wazuh-agent status 2>/dev/null | grep "running" > /dev/null 2>&1; then
service wazuh-agent stop > /dev/null 2>&1
fi
${DIR}/bin/wazuh-control stop > /dev/null 2>&1

# Save the conffiles
mkdir -p ${DIR}/tmp/conffiles
Expand All @@ -93,8 +46,8 @@ case "$1" in
;;

failed-upgrade)
if [ -f ${DIR}/bin/wazuh-control ]; then
${DIR}/bin/wazuh-control stop > /dev/null 2>&1
if [ -f ]; then

fi
;;

Expand Down
9 changes: 1 addition & 8 deletions packages/debs/SPECS/wazuh-manager/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ case "$1" in
# Remove groups backup files
rm -rf ${DIR}/backup/groups

# Generation auto-signed certificate if not exists
if [ ! -f "${DIR}/etc/sslmanager.key" ] && [ ! -f "${DIR}/etc/sslmanager.cert" ]; then
${DIR}/bin/wazuh-authd -C 365 -B 2048 -S "/C=US/ST=California/CN=Wazuh/" -K ${DIR}/etc/sslmanager.key -X ${DIR}/etc/sslmanager.cert 2>/dev/null
fi

chmod 640 ${DIR}/etc/sslmanager.cert ${DIR}/etc/sslmanager.key > /dev/null 2>&1 || true

# For the etc dir
Expand Down Expand Up @@ -277,9 +272,7 @@ case "$1" in
systemctl daemon-reload > /dev/null 2>&1
systemctl restart wazuh-manager.service > /dev/null 2>&1
elif command -v service > /dev/null 2>&1 ; then
service wazuh-manager restart > /dev/null 2>&1
else
${DIR}/bin/wazuh-control restart > /dev/null 2>&1
service wazuh-manager restart > /dev/null 2>&1
fi
fi
fi
Expand Down
10 changes: 1 addition & 9 deletions packages/debs/SPECS/wazuh-manager/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ case "$1" in
elif command -v service > /dev/null 2>&1 && service wazuh-manager status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-manager stop > /dev/null 2>&1
touch ${WAZUH_TMP_DIR}/wazuh.restart
elif ${DIR}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch ${WAZUH_TMP_DIR}/wazuh.restart
elif ${DIR}/bin/ossec-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch ${WAZUH_TMP_DIR}/wazuh.restart
fi
${DIR}/bin/ossec-control stop > /dev/null 2>&1 || ${DIR}/bin/wazuh-control stop > /dev/null 2>&1
if pgrep -f ossec-authd > /dev/null 2>&1; then
kill -15 $(pgrep -f ossec-authd)
fi

if [ -d ${DIR}/logs/ossec ]; then
Expand All @@ -54,7 +46,7 @@ case "$1" in
if [ -f /etc/ossec-init.conf ]; then
. /etc/ossec-init.conf
else
VERSION=$(${DIR}/bin/wazuh-control info -v)
VERSION=$(${DIR}/bin/wazuh-control info -v)
fi

# Get the major and minor version
Expand Down
5 changes: 1 addition & 4 deletions packages/debs/SPECS/wazuh-manager/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ case "$1" in
elif command -v service > /dev/null 2>&1 && service wazuh-manager status 2>/dev/null | grep "running" > /dev/null 2>&1; then
service wazuh-manager stop > /dev/null 2>&1
fi
${DIR}/bin/wazuh-control stop > /dev/null 2>&1

# Purging files
rm -rf ${DIR}/stats/*
Expand Down Expand Up @@ -62,9 +61,7 @@ case "$1" in
;;

failed-upgrade)
if [ -f ${DIR}/bin/wazuh-control ]; then
${DIR}/bin/wazuh-control stop > /dev/null 2>&1
fi

;;

*)
Expand Down
2 changes: 1 addition & 1 deletion packages/macos/package_files/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,5 @@ fi

if [ -n "${upgrade}" ] && [ -n "${restart}" ]; then
echo "Restarting Wazuh..."
${DIR}/bin/wazuh-control restart

fi
24 changes: 23 additions & 1 deletion packages/macos/package_files/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,31 @@ if [ -d "${DIR}" ]; then
rm -f "${DIR}/WAZUH_RESTART"
fi

<<<<<<< HEAD
# Stops the agent before upgrading it
if ${DIR}/bin/wazuh-control status | grep "is running" > /dev/null 2>&1; then
=======
touch "${DIR}/WAZUH_PKG_UPGRADE"
upgrade="true"

if | grep "is running" > /dev/null 2>&1; then
>>>>>>> 058865e67c (refactor: removed references to deprecated daemons in packages files)
touch "${DIR}/WAZUH_RESTART"
${DIR}/bin/wazuh-control stop
restart="true"
elif ${DIR}/bin/ossec-control status | grep "is running" > /dev/null 2>&1; then
elif | grep "is running" > /dev/null 2>&1; then
touch "${DIR}/WAZUH_RESTART"
${DIR}/bin/ossec-control stop
restart="true"
fi

<<<<<<< HEAD
=======
# Stops the agent before upgrading it
echo "Stopping the agent before upgrading it."

if [ -n "${upgrade}" ]; then
>>>>>>> 058865e67c (refactor: removed references to deprecated daemons in packages files)
echo "Backing up configuration files to ${DIR}/config_files/"
mkdir -p ${DIR}/config_files/
cp -r ${DIR}/etc/{ossec.conf,client.keys,local_internal_options.conf,shared} ${DIR}/config_files/
Expand Down Expand Up @@ -98,6 +112,14 @@ if [[ ${new_uid} != ${new_gid} ]]
exit 5;
fi

<<<<<<< HEAD
=======
# Stops the agent before upgrading it
if [ -f ]; then
elif [ -f ]; then
fi

>>>>>>> 058865e67c (refactor: removed references to deprecated daemons in packages files)
# Creating the group
echo "Checking group..."
if [[ $(dscl . -read /Groups/wazuh) ]]
Expand Down
1 change: 0 additions & 1 deletion packages/macos/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/sh

## Stop and remove application
sudo /Library/Ossec/bin/wazuh-control stop
sudo /bin/rm -r /Library/Ossec*

# remove launchdaemons
Expand Down
10 changes: 2 additions & 8 deletions packages/rpms/SPECS/wazuh-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,12 @@ if [ $1 = 2 ]; then
elif command -v service > /dev/null 2>&1 && service wazuh-agent status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-agent stop > /dev/null 2>&1
touch %{_localstatedir}/tmp/wazuh.restart
elif %{_localstatedir}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch %{_localstatedir}/tmp/wazuh.restart
elif %{_localstatedir}/bin/ossec-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch %{_localstatedir}/tmp/wazuh.restart
fi
%{_localstatedir}/bin/ossec-control stop > /dev/null 2>&1 || %{_localstatedir}/bin/wazuh-control stop > /dev/null 2>&1
fi

%post

echo "VERSION=\"$(%{_localstatedir}/bin/wazuh-control info -v)\"" > /etc/ossec-init.conf
echo "VERSION=\"\"" > /etc/ossec-init.conf
if [ $1 = 2 ]; then
if [ -d %{_localstatedir}/logs/ossec ]; then
rm -rf %{_localstatedir}/logs/wazuh
Expand Down Expand Up @@ -425,7 +420,6 @@ if [ $1 = 0 ]; then
elif command -v service > /dev/null 2>&1 && service wazuh-agent status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-agent stop > /dev/null 2>&1
fi
%{_localstatedir}/bin/wazuh-control stop > /dev/null 2>&1

# Remove the SELinux policy
if command -v getenforce > /dev/null 2>&1 && command -v semodule > /dev/null 2>&1; then
Expand Down Expand Up @@ -518,7 +512,7 @@ if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then
elif command -v service > /dev/null 2>&1; then
service wazuh-agent restart > /dev/null 2>&1
else
%{_localstatedir}/bin/wazuh-control restart > /dev/null 2>&1

fi
fi

Expand Down
47 changes: 6 additions & 41 deletions packages/rpms/SPECS/wazuh-manager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,13 @@ fi
if [ $1 = 2 ]; then
if command -v systemctl > /dev/null 2>&1 && systemctl > /dev/null 2>&1 && systemctl is-active --quiet wazuh-manager > /dev/null 2>&1; then
systemctl stop wazuh-manager.service > /dev/null 2>&1
%{_localstatedir}/bin/ossec-control stop > /dev/null 2>&1
touch %{_localstatedir}/tmp/wazuh.restart
# Check for SysV
elif command -v service > /dev/null 2>&1 && service wazuh-manager status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-manager stop > /dev/null 2>&1
%{_localstatedir}/bin/ossec-control stop > /dev/null 2>&1
touch %{_localstatedir}/tmp/wazuh.restart
elif %{_localstatedir}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch %{_localstatedir}/tmp/wazuh.restart
elif %{_localstatedir}/bin/ossec-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
touch %{_localstatedir}/tmp/wazuh.restart
fi
%{_localstatedir}/bin/ossec-control stop > /dev/null 2>&1 || %{_localstatedir}/bin/wazuh-control stop > /dev/null 2>&1
fi
if pgrep -f ossec-authd > /dev/null 2>&1; then
kill -15 $(pgrep -f ossec-authd)

fi

# Remove/relocate existing SQLite databases
Expand Down Expand Up @@ -272,7 +263,7 @@ if [ $1 = 2 ]; then
. %{_sysconfdir}/ossec-init.conf
else
# Ask wazuh-control the version
VERSION=$(%{_localstatedir}/bin/wazuh-control info -v)
VERSION=$()
fi

# Get the major and minor version
Expand Down Expand Up @@ -302,7 +293,7 @@ fi

%post

echo "VERSION=\"$(%{_localstatedir}/bin/wazuh-control info -v)\"" > /etc/ossec-init.conf
echo "VERSION=\"$()\"" > /etc/ossec-init.conf

# Upgrade install code block
if [ $1 = 2 ]; then
Expand Down Expand Up @@ -351,7 +342,7 @@ fi

# Generation auto-signed certificate if not exists
if [ ! -f "%{_localstatedir}/etc/sslmanager.key" ] && [ ! -f "%{_localstatedir}/etc/sslmanager.cert" ]; then
%{_localstatedir}/bin/wazuh-authd -C 365 -B 2048 -S "/C=US/ST=California/CN=Wazuh/" -K %{_localstatedir}/etc/sslmanager.key -X %{_localstatedir}/etc/sslmanager.cert 2>/dev/null

chmod 640 %{_localstatedir}/etc/sslmanager.key
chmod 640 %{_localstatedir}/etc/sslmanager.cert
fi
Expand Down Expand Up @@ -518,7 +509,7 @@ if [ $1 = 0 ]; then
elif command -v service > /dev/null 2>&1 && service wazuh-manager status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
service wazuh-manager stop > /dev/null 2>&1
fi
%{_localstatedir}/bin/wazuh-control stop > /dev/null 2>&1


# Remove the SELinux policy
if command -v getenforce > /dev/null 2>&1 && command -v semodule > /dev/null 2>&1; then
Expand Down Expand Up @@ -589,7 +580,7 @@ if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then
elif command -v service > /dev/null 2>&1 ; then
service wazuh-manager restart > /dev/null 2>&1
else
%{_localstatedir}/bin/wazuh-control restart > /dev/null 2>&1

fi
fi

Expand Down Expand Up @@ -639,34 +630,8 @@ rm -fr %{buildroot}
%dir %attr(750, wazuh, wazuh) %{_localstatedir}/backup/agents
%dir %attr(750, root, wazuh) %{_localstatedir}/backup/shared
%dir %attr(750, root, wazuh) %{_localstatedir}/bin
%attr(750, root, root) %{_localstatedir}/bin/agent_control
%attr(750, root, wazuh) %{_localstatedir}/bin/agent_groups
%attr(750, root, wazuh) %{_localstatedir}/bin/agent_upgrade
%attr(750, root, root) %{_localstatedir}/bin/clear_stats
%attr(750, root, wazuh) %{_localstatedir}/bin/cluster_control
%attr(750, root, root) %{_localstatedir}/bin/manage_agents
%attr(750, root, root) %{_localstatedir}/bin/wazuh-agentlessd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-analysisd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-authd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-control
%attr(750, root, root) %{_localstatedir}/bin/wazuh-csyslogd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-dbd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-execd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-integratord
%attr(750, root, root) %{_localstatedir}/bin/wazuh-logcollector
%attr(750, root, root) %{_localstatedir}/bin/wazuh-logtest-legacy
%attr(750, root, wazuh) %{_localstatedir}/bin/wazuh-logtest
%attr(750, root, root) %{_localstatedir}/bin/wazuh-maild
%attr(750, root, root) %{_localstatedir}/bin/wazuh-monitord
%attr(750, root, root) %{_localstatedir}/bin/wazuh-regex
%attr(750, root, root) %{_localstatedir}/bin/wazuh-remoted
%attr(750, root, root) %{_localstatedir}/bin/wazuh-reportd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-syscheckd
%attr(750, root, wazuh) %{_localstatedir}/bin/verify-agent-conf
%attr(750, root, wazuh) %{_localstatedir}/bin/wazuh-apid
%attr(750, root, wazuh) %{_localstatedir}/bin/wazuh-clusterd
%attr(750, root, root) %{_localstatedir}/bin/wazuh-db
%attr(750, root, root) %{_localstatedir}/bin/wazuh-modulesd
%attr(750, root, wazuh) %{_localstatedir}/bin/rbac_control
%attr(750, root, wazuh) %{_localstatedir}/bin/wazuh-keystore
%dir %attr(770, wazuh, wazuh) %{_localstatedir}/etc
Expand Down

0 comments on commit 19fce98

Please sign in to comment.