-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2053 from wazuh/1626-fix-rhel9-derived-services
Fix init.d file installation for Alma Linux and Rocky Linux
- Loading branch information
Showing
20 changed files
with
606 additions
and
14 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
.github/actions/ghcr-pull-and-push/build_and_push_image_to_ghcr.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
GITHUB_PUSH_SECRET=$1 | ||
GITHUB_USER=$2 | ||
DOCKER_IMAGE_NAME=$3 | ||
BUILD_CONTEXT=$4 | ||
DOCKERFILE_PATH="$BUILD_CONTEXT/Dockerfile" | ||
if [ -n "$5" ]; then | ||
DOCKER_IMAGE_TAG=$5 | ||
else | ||
DOCKER_IMAGE_TAG="latest" | ||
fi | ||
GITHUB_REPOSITORY="wazuh/wazuh-packages" | ||
GITHUB_OWNER="wazuh" | ||
IMAGE_ID=ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} | ||
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]') | ||
|
||
# Login to GHCR | ||
echo ${GITHUB_PUSH_SECRET} | docker login https://ghcr.io -u $GITHUB_USER --password-stdin | ||
|
||
# Build image | ||
echo build -t ${IMAGE_ID} -f ${DOCKERFILE_PATH} ${BUILD_CONTEXT} | ||
docker build -t ${IMAGE_ID} -f ${DOCKERFILE_PATH} ${BUILD_CONTEXT} | ||
docker push ${IMAGE_ID} |
19 changes: 19 additions & 0 deletions
19
.github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
GITHUB_PUSH_SECRET=$1 | ||
GITHUB_USER=$2 | ||
DOCKER_IMAGE_NAME=$3 | ||
if [ -n "$4" ]; then | ||
DOCKER_IMAGE_TAG="$4" | ||
else | ||
DOCKER_IMAGE_TAG="latest" | ||
fi | ||
GITHUB_REPOSITORY="wazuh/wazuh-packages" | ||
GITHUB_OWNER="wazuh" | ||
IMAGE_ID=ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} | ||
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]') | ||
|
||
# Login to GHCR | ||
echo ${GITHUB_PUSH_SECRET} | docker login https://ghcr.io -u $GITHUB_USER --password-stdin | ||
|
||
# Pull and rename image | ||
docker pull ${IMAGE_ID} | ||
docker image tag ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
echo "Installing Wazuh $2." | ||
|
||
source /etc/os-release | ||
if [ "$ID" = "centos" ] && [ "$VERSION_ID" = "8" ]; then | ||
find /etc/yum.repos.d/ -type f -exec sed -i 's/mirrorlist/#mirrorlist/g' {} \; | ||
find /etc/yum.repos.d/ -type f -exec sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' {} \; | ||
fi | ||
|
||
if [ -n "$(command -v yum)" ]; then | ||
sys_type="yum" | ||
elif [ -n "$(command -v apt-get)" ]; then | ||
sys_type="apt-get" | ||
apt-get update | ||
apt-get install -y systemd | ||
else | ||
common_logger -e "Couldn't find type of system" | ||
exit 1 | ||
fi | ||
|
||
$sys_type install -y "/packages/$1" | ||
|
||
echo "Enabling Wazuh $2." | ||
systemctl enable wazuh-$2 | ||
if [ "$?" -eq 0 ]; then | ||
echo "Wazuh $2 enabled - Test passed correctly." | ||
exit 0 | ||
else | ||
echo "Error: Wazuh $2 not enabled." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Build Wazuh Packages - DEB - amd64 and i386 | ||
on: | ||
pull_request: | ||
paths: | ||
- 'debs/SPECS/*' | ||
- 'debs/generate_debian_package.sh' | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
Wazuh-agent-deb-package-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
TYPE: [agent, manager] | ||
ARCHITECTURE : [amd64, i386] | ||
exclude: | ||
- TYPE: manager | ||
ARCHITECTURE: i386 | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
cancel_others: 'true' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
skip_after_successful_duplicate: 'false' | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Get changed files | ||
uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
deb_images: | ||
- 'debs/Debian/**' | ||
- 'debs/build.sh' | ||
deb_images_i386: | ||
- 'debs/Debian/i386/**' | ||
- 'debs/build.sh' | ||
deb_images_amd64: | ||
- 'debs/Debian/amd64/**' | ||
- 'debs/build.sh' | ||
deb_packages: | ||
- 'debs/SPECS/**' | ||
- 'debs/generate_debian_package.sh' | ||
- name: Set tag and container name | ||
run: | | ||
MAJOR=$(sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/' $GITHUB_WORKSPACE/VERSION) | ||
if [ "${{ steps.changes.outputs.deb_images }}" == "true" ]; then echo "TAG=${{ github.head_ref }}" >> $GITHUB_ENV; else echo "TAG=$MAJOR" >> $GITHUB_ENV ; fi | ||
if [ $MAJOR == "4.6" ]; then echo "VERSION=master" >> $GITHUB_ENV $ ; else echo "VERSION=$MAJOR" >> $GITHUB_ENV; fi | ||
echo "CONTAINER_NAME=deb_builder_${{ matrix.ARCHITECTURE }}" >> $GITHUB_ENV | ||
- name: Download docker image for package building | ||
run: | | ||
bash $GITHUB_WORKSPACE/.github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh ${{ secrets.GITHUB_TOKEN }} ${{ github.actor}} $CONTAINER_NAME ${{ env.TAG }} | ||
- name: Build the ${{ matrix.ARCHITECTURE }} deb Wazuh ${{ matrix.TYPE }} package | ||
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64') | ||
working-directory: ./debs | ||
run: | | ||
REVISION="${{ github.head_ref }}" | ||
bash generate_debian_package.sh -b ${{ env.VERSION }} -t ${{ matrix.TYPE }} -a ${{ matrix.ARCHITECTURE }} --dev -j 2 --dont-build-docker --tag ${{ env.TAG }} -r $REVISION | ||
echo "PACKAGE_NAME=$(ls ./output | grep .deb | head -n 1)" >> $GITHUB_ENV | ||
- name: Upload Wazuh ${{ matrix.TYPE }} ${{ matrix.ARCHITECTURE }} package as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.PACKAGE_NAME }} | ||
path: ${{github.workspace}}/debs/output/${{ env.PACKAGE_NAME }} | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Build Wazuh Packages - RPM - x86_64 and i386 | ||
on: | ||
pull_request: | ||
paths: | ||
- 'rpms/SPECS/*' | ||
- 'rpms/generate_rpm_package.sh' | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
|
||
jobs: | ||
Wazuh-agent-rpm-package-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
TYPE: [agent, manager] | ||
ARCHITECTURE : [x86_64, i386] | ||
exclude: | ||
- TYPE: manager | ||
ARCHITECTURE: i386 | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
cancel_others: 'true' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
skip_after_successful_duplicate: 'false' | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Get changed files | ||
uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
rpm_images: | ||
- 'rpms/CentOS/**' | ||
- 'rpms/build.sh' | ||
rpm_images_i386: | ||
- 'rpms/CentOS/6/i386/**' | ||
- 'rpms/build.sh' | ||
rpm_images_x86_64: | ||
- 'rpms/CentOS/6/x86_64/**' | ||
- 'rpms/build.sh' | ||
rpm_packages: | ||
- 'rpms/SPECS/**' | ||
- 'rpms/generate_rpm_package.sh' | ||
- name: Set tag and container name | ||
run: | | ||
MAJOR=$(sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/' $GITHUB_WORKSPACE/VERSION) | ||
if [ "${{ steps.changes.outputs.rpm_images }}" == "true" ]; then echo "TAG=${{ github.head_ref }}" >> $GITHUB_ENV; else echo "TAG=$MAJOR" >> $GITHUB_ENV ; fi | ||
if [ $MAJOR == "4.6" ]; then echo "VERSION=master" >> $GITHUB_ENV $ ; else echo "VERSION=$MAJOR" >> $GITHUB_ENV; fi | ||
if [ "${{ matrix.ARCHITECTURE }}" == "x86_64" ]; then echo "CONTAINER_NAME=rpm_builder_x86" >> $GITHUB_ENV ; else echo "CONTAINER_NAME=rpm_builder_${{ matrix.ARCHITECTURE }}" >> $GITHUB_ENV ; fi | ||
- name: Download docker image for package building | ||
run: | | ||
bash $GITHUB_WORKSPACE/.github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh ${{ secrets.GITHUB_TOKEN }} ${{ github.actor}} $CONTAINER_NAME ${{ env.TAG }} | ||
- name: Build the ${{ matrix.ARCHITECTURE }} rpm Wazuh ${{ matrix.TYPE }} package | ||
if : steps.changes.outputs.rpm_packages == 'true' || (steps.changes.outputs.rpm_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.rpm_images_x86_64 == 'true' && matrix.ARCHITECTURE == 'x86_64') | ||
working-directory: ./rpms | ||
run: | | ||
REVISION=$( echo ${{ github.head_ref }} | sed 's/-/./g' ) | ||
bash generate_rpm_package.sh -b ${{ env.VERSION }} -t ${{ matrix.TYPE }} -a ${{ matrix.ARCHITECTURE }} --dev -j 2 --dont-build-docker --tag ${{ env.TAG }} -r $REVISION | ||
echo "PACKAGE_NAME=$(ls ./output | grep .rpm | head -n 1)" >> $GITHUB_ENV | ||
- name: Upload Wazuh ${{ matrix.TYPE }} ${{ matrix.ARCHITECTURE }} package as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.PACKAGE_NAME }} | ||
path: ${{github.workspace}}/rpms/output/${{ env.PACKAGE_NAME }} | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Clean workflow runs | ||
on: | ||
schedule: | ||
- cron: '0 0 * * 5' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Clean-runs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete workflow runs | ||
uses: dmvict/clean-workflow-runs@v1.0.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
run_conclusions: | | ||
cancelled | ||
skipped | ||
timed_out | ||
save_period: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Test install and enable Wazuh agent and manager - DEB | ||
on: | ||
pull_request: | ||
paths: | ||
- 'debs/SPECS/*' | ||
- 'debs/generate_debian_package.sh' | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
|
||
Wait-for-package-building: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Cancel previous runs | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
cancel_others: 'true' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
skip_after_successful_duplicate: 'false' | ||
|
||
- name: Wait for the package to be built | ||
uses: ArcticLampyrid/action-wait-for-workflow@v1.0.3 | ||
id: wait-for-build | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
workflow: build-deb-packages.yml | ||
sha: ${{ github.event.pull_request.head.sha || github.sha }} | ||
wait-interval: 60 | ||
|
||
Test-install-and-enable-deb-systems: | ||
needs: Wait-for-package-building | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
distro_name: ['ubuntu:xenial', 'ubuntu:bionic', 'ubuntu:focal', 'ubuntu:jammy', 'debian:stretch', 'debian:buster', 'debian:bullseye'] | ||
type: [agent, manager] | ||
arch: [amd64, i386] | ||
exclude: | ||
- type: manager | ||
arch: i386 | ||
- distro_name: 'ubuntu:jammy' | ||
arch: i386 | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get changed files | ||
uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
deb_images: | ||
- 'debs/Debian/**' | ||
- 'debs/build.sh' | ||
deb_images_i386: | ||
- 'debs/Debian/i386/**' | ||
- 'debs/build.sh' | ||
deb_images_amd64: | ||
- 'debs/Debian/amd64/**' | ||
- 'debs/build.sh' | ||
deb_packages: | ||
- 'debs/SPECS/**' | ||
- 'debs/generate_debian_package.sh' | ||
- name: Setup directories and variables | ||
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64') | ||
run: | | ||
VERSION=$(cat $GITHUB_WORKSPACE/VERSION) | ||
REVISION=$( echo ${{ github.head_ref }}) | ||
echo "PACKAGE_NAME=wazuh-${{ matrix.type }}_${VERSION}-${REVISION}_${{ matrix.arch }}.deb" >> $GITHUB_ENV | ||
- name: Download the Wazuh ${{ matrix.type }} package for ${{ matrix.system.NAME }} | ||
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64') | ||
id: download-artifact | ||
continue-on-error: true | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: build-deb-packages.yml | ||
workflow_conclusion: success | ||
name: ${{env.PACKAGE_NAME}} | ||
if_no_artifact_found: fail | ||
|
||
- name: Move the Wazuh ${{ matrix.type }} package for ${{ matrix.distro_name }} to the packages directory | ||
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64') | ||
run: | | ||
mkdir $GITHUB_WORKSPACE/packages | ||
mv ${{env.PACKAGE_NAME}} $GITHUB_WORKSPACE/packages | ||
- name: Launch docker | ||
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64') | ||
run: sudo docker run -v $GITHUB_WORKSPACE/.github/actions/test-install-enable/:/tests -v $GITHUB_WORKSPACE/packages/:/packages ${{ matrix.arch }}/${{ matrix.distro_name }} bash /tests/install_and_enable.sh $PACKAGE_NAME ${{ matrix.type }} |
Oops, something went wrong.