Skip to content

Commit

Permalink
Add Alma and Rocky linux to system check
Browse files Browse the repository at this point in the history
  • Loading branch information
DFolchA committed Jul 19, 2023
1 parent 8546ea4 commit 178aa87
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
28 changes: 22 additions & 6 deletions rpms/SPECS/wazuh-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/rh
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/sles/{11,12,15}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/suse/{11,12}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/fedora/{29,30,31,32,33,34}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/almalinux/{8}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/almalinux/{8,9}

cp -r ruleset/sca/{generic,centos,rhel,sles,amazon,almalinux} ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp

Expand Down Expand Up @@ -276,18 +276,35 @@ rm -rf %{_localstatedir}/packages_files

# Remove unnecessary files from shared directory
rm -f %{_localstatedir}/etc/shared/*.rpmnew

#AlmaLinux
if [ -r "/etc/almalinux-release" ]; then
DIST_NAME=almalinux
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/almalinux-release`
#Rocky
elif [ -r "/etc/rocky-release" ]; then
DIST_NAME=rocky
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/rocky-release`
# CentOS
if [ -r "/etc/centos-release" ]; then
DIST_NAME="centos"
elif [ -r "/etc/centos-release" ]; then
if grep -q "AlmaLinux" /etc/centos-release; then
DIST_NAME=almalinux
elif grep -q "Rocky" /etc/centos-release; then
DIST_NAME=almalinux
else
DIST_NAME="centos"
fi
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/centos-release`
# Fedora
elif [ -r "/etc/fedora-release" ]; then
DIST_NAME="fedora"
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/fedora-release`
# RedHat
elif [ -r "/etc/redhat-release" ]; then
if grep -q "CentOS" /etc/redhat-release; then
if grep -q "AlmaLinux" /etc/redhat-release; then
DIST_NAME=almalinux
elif grep -q "Rocky" /etc/redhat-release; then
DIST_NAME=almalinux
elif grep -q "CentOS" /etc/redhat-release; then
DIST_NAME="centos"
else
DIST_NAME="rhel"
Expand Down Expand Up @@ -339,7 +356,6 @@ else
fi

SCA_TMP_FILE="${SCA_TMP_DIR}/sca.files"

if [ -r ${SCA_TMP_FILE} ]; then

rm -f %{_localstatedir}/ruleset/sca/* || true
Expand Down
28 changes: 23 additions & 5 deletions rpms/SPECS/wazuh-manager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/su
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/sunos
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/windows
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/fedora/{29,30,31,32,33,34}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/almalinux/{8}
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp/almalinux/{8,9}

cp -r ruleset/sca/{applications,generic,mongodb,nginx,oracledb,centos,darwin,debian,rhel,sles,sunos,windows,amazon,ubuntu,almalinux} ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/sca-%{version}-%{release}-tmp

Expand Down Expand Up @@ -319,7 +319,7 @@ if [ $1 = 1 ]; then
%{_localstatedir}/packages_files/manager_installation_scripts/add_localfiles.sh %{_localstatedir} >> %{_localstatedir}/etc/ossec.conf
fi

# We create this fix for the operating system that decraped the SySV. For now, this fix is for suse/openSUSE
# We create this fix for the operating system that deprecated SySV. For now, this fix is for suse/openSUSE
sles=""
if [ -f /etc/SuSE-release ]; then
sles="suse"
Expand Down Expand Up @@ -354,17 +354,35 @@ fi
rm -f %{_localstatedir}/etc/shared/ar.conf >/dev/null 2>&1
rm -f %{_localstatedir}/etc/shared/merged.mg >/dev/null 2>&1

#AlmaLinux
if [ -r "/etc/almalinux-release" ]; then
DIST_NAME=almalinux
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/almalinux-release`
#Rocky
elif [ -r "/etc/rocky-release" ]; then
DIST_NAME=rocky
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/rocky-release`
# CentOS
if [ -r "/etc/centos-release" ]; then
DIST_NAME="centos"
elif [ -r "/etc/centos-release" ]; then
if grep -q "AlmaLinux" /etc/centos-release; then
DIST_NAME=almalinux
elif grep -q "Rocky" /etc/centos-release; then
DIST_NAME=almalinux
else
DIST_NAME="centos"
fi
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/centos-release`
# Fedora
elif [ -r "/etc/fedora-release" ]; then
DIST_NAME="fedora"
DIST_VER=`sed -rn 's/.* ([0-9]{1,2})\.*[0-9]{0,2}.*/\1/p' /etc/fedora-release`
# RedHat
elif [ -r "/etc/redhat-release" ]; then
if grep -q "CentOS" /etc/redhat-release; then
if grep -q "AlmaLinux" /etc/redhat-release; then
DIST_NAME=almalinux
elif grep -q "Rocky" /etc/redhat-release; then
DIST_NAME=almalinux
elif grep -q "CentOS" /etc/redhat-release; then
DIST_NAME="centos"
else
DIST_NAME="rhel"
Expand Down

0 comments on commit 178aa87

Please sign in to comment.