Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply changes master #831

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 25 additions & 30 deletions aix/SPECS/4.3.0/wazuh-agent-4.3.0-aix.spec
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,38 @@ if [ $1 = 1 ]; then
fi

if [ $1 = 2 ]; then
if %{_localstatedir}/bin/wazuh-control status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
if /etc/rc.d/init.d/wazuh-agent status 2>/dev/null | grep "is running" > /dev/null 2>&1; then
/etc/rc.d/init.d/wazuh-agent stop > /dev/null 2>&1 || :
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
if [ $1 = 2 ]; then
if [ -d %{_localstatedir}/logs/ossec ]; then
rm -rf %{_localstatedir}/logs/wazuh
cp -rp %{_localstatedir}/logs/ossec %{_localstatedir}/logs/wazuh
cp -rp %{_localstatedir}/logs/ossec %{_localstatedir}/tmp/logs/wazuh > /dev/null 2>&1
rm -rf %{_localstatedir}/logs/ossec/*
rm -rf %{_localstatedir}/logs/ossec/.??*
fi

if [ -d %{_localstatedir}/queue/ossec ]; then
cp -rp %{_localstatedir}/queue/ossec %{_localstatedir}/tmp/queue/sockets > /dev/null 2>&1
rm -rf %{_localstatedir}/queue/ossec/*
rm -rf %{_localstatedir}/queue/ossec/.??*
fi
fi

%post

if [ $1 = 2 ]; then
if [ -d %{_localstatedir}/tmp/logs/wazuh ]; then
rm -rf %{_localstatedir}/logs/wazuh
mv %{_localstatedir}/tmp/logs/ossec %{_localstatedir}/logs/wazuh> /dev/null 2>&1
fi

if [ -d %{_localstatedir}/tmp/queue/sockets ]; then
rm -rf %{_localstatedir}/queue/sockets
cp -rp %{_localstatedir}/queue/ossec %{_localstatedir}/queue/sockets
mv %{_localstatedir}/tmp/queue/ossec %{_localstatedir}/queue/sockets > /dev/null 2>&1
fi
fi

Expand Down Expand Up @@ -160,17 +175,6 @@ rm -f %{_localstatedir}/tmp/add_localfiles.sh

chmod 0660 %{_localstatedir}/etc/ossec.conf

# Restart wazuh-agent when manager settings are in place
if grep '<server-ip>.*</server-ip>' %{_localstatedir}/etc/ossec.conf | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' > /dev/null 2>&1; then
/etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || :
fi
if grep '<server-hostname>.*</server-hostname>' %{_localstatedir}/etc/ossec.conf > /dev/null 2>&1; then
/etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || :
fi
if grep '<address>.*</address>' %{_localstatedir}/etc/ossec.conf | grep -v 'MANAGER_IP' > /dev/null 2>&1; then
/etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || :
fi

# Remove old ossec user and group if exists and change ownwership of files

if grep "^ossec:" /etc/group > /dev/null 2>&1; then
Expand All @@ -190,6 +194,11 @@ if grep "^ossec:" /etc/group > /dev/null 2>&1; then
rmgroup ossec
fi

if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then
rm -f %{_localstatedir}/tmp/wazuh.restart
/etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || :
fi

%preun

if [ $1 = 0 ]; then
Expand Down Expand Up @@ -219,20 +228,6 @@ if [ $1 = 0 ];then
rm -rf %{_localstatedir}/ruleset
fi

%posttrans
if [ -f %{_localstatedir}/tmp/wazuh.restart ]; then
rm -f %{_localstatedir}/tmp/wazuh.restart
/etc/rc.d/init.d/wazuh-agent restart > /dev/null 2>&1 || :
fi

if [ -d %{_localstatedir}/logs/ossec ]; then
rm -rf %{_localstatedir}/logs/ossec/
fi

if [ -d %{_localstatedir}/queue/ossec ]; then
rm -rf %{_localstatedir}/queue/ossec/
fi

%clean
rm -fr %{buildroot}

Expand Down
3 changes: 2 additions & 1 deletion rpms/SPECS/4.3.0/wazuh-agent-4.3.0.spec
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ if [ -d %{_localstatedir}/queue/ossec ]; then
fi

if [ -f %{_sysconfdir}/ossec-init.conf ]; then
rm -rf %{_sysconfdir}/ossec-init.conf
rm -f %{_sysconfdir}/ossec-init.conf
rm -f %{_localstatedir}/etc/ossec-init.conf
fi

%clean
Expand Down
3 changes: 2 additions & 1 deletion rpms/SPECS/4.3.0/wazuh-manager-4.3.0.spec
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ if [ -d %{_localstatedir}/queue/ossec ]; then
fi

if [ -f %{_sysconfdir}/ossec-init.conf ]; then
rm -rf %{_sysconfdir}/ossec-init.conf
rm -f %{_sysconfdir}/ossec-init.conf
rm -f %{_localstatedir}/etc/ossec-init.conf
fi

%triggerin -- glibc
Expand Down