Skip to content

Latest commit

 

History

History
290 lines (207 loc) · 7.06 KB

BUILD.md

File metadata and controls

290 lines (207 loc) · 7.06 KB

Build Instructions

The following dependencies are required for this project:

  • Git
  • CMake at least 3.22
  • Make
  • C++ compiler (GCC 10 or Clang 13, coroutines support needed)
  • Zip (for vcpkg)
  • Curl (for vcpkg)
  • Tar (for vcpkg)
  • Ninja-build (for vcpkg)
  • Pkg-config

Compilation steps for Linux

  1. Installing Dependencies on Debian

    To install the necessary dependencies on a Debian-based system, run the following commands:

    sudo apt-get update
    sudo apt-get install cmake make gcc git zip curl tar ninja-build pkg-config wget gnupg lsb-release software-properties-common libbz2-dev
    wget https://apt.llvm.org/llvm.sh
    chmod +x llvm.sh
    sudo ./llvm.sh 18
    sudo apt-get update
    sudo apt-get install -y clang-tidy-18 autopoint libtool zlib1g-dev libgcrypt20-dev libmagic-dev libpopt-dev libmagic-dev libsqlite3-dev liblua5.4-dev gettext libarchive-dev
  2. Clone the Repository

    First, clone the repository using the following command:

    git clone https://github.com/wazuh/wazuh-agent.git
  3. Initialize Submodules

    The project uses submodules, so you need to initialize and update them. Run the following commands:

    cd wazuh-agent
    git submodule update --init --recursive
  4. Configure and Build the Project

    cmake src -B build
    cmake --build build

    If you want to include tests, configure the project with the following command:

    cmake src -B build -DBUILD_TESTS=1
    cmake --build build
  5. Run the Agent

    To run the agent in the foreground from the CLI

    You can start and stop the agent, and get status with:

    ./wazuh-agent --run
    ./wazuh-agent --stop
    ./wazuh-agent --restart
    ./wazuh-agent --status

    To run the agent as a systemd service

    Copy the file src/agent/service/wazuh-agent.service to /usr/lib/systemd/system/. Replace the placeholder WAZUH_HOME to your wazuh-agent executable directory. Reload unit files.

    systemctl daemon-reload

    Enable service.

    systemctl enable wazuh-agent

    You can start and stop the agent, and get status from systemctl:

    systemctl start wazuh-agent
    systemctl stop wazuh-agent
    systemctl is-active wazuh-agent
    systemctl status wazuh-agent
  6. Run tests

    If built with CMake and -DBUILD_TESTS=1, you can run tests with:

    ctest --test-dir build --output-log build

Compilation steps for macOS

  1. Install brew, a package manager for macOS

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install dependencies

    brew install automake autoconf libtool cmake pkg-config openssl
  3. Clone the Repository

    Clone the repository:

    git clone https://github.com/wazuh/wazuh-agent.git
  4. Initialize Submodules

    The project uses submodules, so you need to initialize and update them. Run the following commands:

    cd wazuh-agent
    git submodule update --init --recursive
  5. Configure and Build the Project

    cmake src -B build
    cmake --build build

    If you want to include tests, configure the project with the following command:

    cmake src -B build -DBUILD_TESTS=1
    cmake --build build
  6. Run the Agent

    To run the agent in the foreground from the CLI

    You can start and stop the agent, and get status with:

    ./wazuh-agent --run
    ./wazuh-agent --stop
    ./wazuh-agent --restart
    ./wazuh-agent --status

    To run the agent as a launchd service

    Copy the file src/agent/service/com.wazuh.agent.plist to /Library/LaunchDaemons/. Edit the file and replace the placeholder path with your wazuh-agent executable directory as well as the working directory.

    sudo chown root:wheel /Library/LaunchDaemons/com.wazuh.agent.plist
    sudo chmod 644 /Library/LaunchDaemons/com.wazuh.agent.plist

    Load the service

    sudo launchctl bootstrap system /Library/LaunchDaemons/com.wazuh.agent.plist

    Verify the service is running

    sudo launchctl print system/com.wazuh.agent
    
  7. Run tests

    If built with CMake and -DBUILD_TESTS=1, you can run tests with:

    ctest --test-dir build --output-log build

Compilation steps for Windows

  1. Installing Dependencies
  • Visual Studio Community 2022 (with MSVC 14)
  • Chocolatey
    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  • Make
    choco install make
  • Cmake 3.30.x
    choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
  • OpenSSL
    choco install openssl
  • Git
  1. Clone the Repository

    First, clone the repository using the following command:

    git clone https://github.com/wazuh/wazuh-agent.git
  2. Initialize Submodules

    The project uses submodules, so you need to initialize and update them. Run the following commands:

    cd wazuh-agent
    git submodule update --init --recursive
  3. Configure and Build the Project

    cmake src -B build -G "Visual Studio 17 2022" -A x64
    cmake --build build

    If you want to include tests, configure the project with the following command:

    cmake src -B build -DBUILD_TESTS=1 -G "Visual Studio 17 2022" -A x64
    cmake --build build --config RelWithDebInfo
  4. Run the Agent

    Install windows service

    .\RelWithDebInfo\wazuh-agent --install-service

    You can start, stop or restart the service from Windows SCM.

    Or from the CLI

    .\RelWithDebInfo\wazuh-agent --start
    .\RelWithDebInfo\wazuh-agent --stop
    .\RelWithDebInfo\wazuh-agent --status

    To remove the service

    .\RelWithDebInfo\wazuh-agent --remove-service
  5. Run tests

    If built with CMake and -DBUILD_TESTS=1, you can run tests with:

    ctest -C RelWithDebInfo --test-dir build --output-log build

Options

Option Description Default
BUILD_TESTS Enable tests compilation OFF
COVERAGE Enable coverage report OFF
ENABLE_CLANG_TIDY Check code with clang-tidy ON
ENABLE_INVENTORY Enable Inventory module ON
ENABLE_LOGCOLLECTOR Enable Logcollector module ON

Notes

  • The project uses vcpkg as a submodule to manage dependencies. By initializing the submodules, vcpkg will automatically fetch the necessary dependencies when running CMake.