Installation on Linux
Relevant source files
The following files were used as context for generating this wiki page:FluentDo Agent provides multiple methods for installation on Linux systems, catering to different use cases from quick deployment to customized builds. Users can either use a convenient installation script to deploy pre-built packages or compile the agent directly from the source code for specific targets.
The primary methods for Linux installation are:
- Package Installation via Script: A shell script that automates the detection of the host environment and installs the appropriate pre-built package.
- Building from Source: Compiling the agent natively or using a container-based build script to create packages for various Linux distributions.
Sources: README.md:104-128, install.sh
Using the Installation Script
The most straightforward way to install FluentDo Agent on a supported Linux distribution is by using the install.sh script. This script handles platform detection, package download, and installation automatically.
Sources: README.md:107-109, install.sh
Quick Install
To download and run the installer:
curl -sSfL https://raw.githubusercontent.com/FluentDo/agent/refs/heads/main/install.sh | bash
This command fetches the latest version of the script and executes it. The script will attempt to identify the OS, download the correct package from https://packages.fluent.do, and install it using the native package manager.
Sources: README.md:108-109, install.sh:844-847
Script Execution Flow
The install.sh script follows a sequence of steps to ensure a successful installation. It begins by checking prerequisites and detecting the system environment, then proceeds to find, download, and install the agent package.
The diagram below illustrates the main execution flow of the install.sh script.
This diagram shows the logical flow of functions called within the main function of the installation script.
Sources: install.sh:783-842
Platform and Distribution Detection
The script automatically detects the operating system, architecture, and Linux distribution to select the correct package.
- Platform Detection (
detect_platform): It usesuname -sanduname -mto determine the OS (e.g.,linux) and architecture (e.g.,amd64,arm64). - Distribution Detection (
detect_distro): It checks for/etc/os-releaseor/etc/lsb-releaseto identify the distribution ID and version. Based on the ID, it determines the package manager and format.
The following table summarizes the supported distributions and their corresponding package formats as identified by the script.
Distribution ID (ID) | Package Manager | Package Format |
|---|---|---|
ubuntu, debian | apt-get | deb |
fedora, rhel, centos | yum | rpm |
rocky, almalinux | yum | rpm |
amazonlinux | yum | rpm |
opensuse-leap, suse, sles | zypper | rpm |
alpine | apk | apk |
For RPM-based distributions, the script uses the major version number (e.g., 8 for RHEL 8). For Debian, it converts the version number to its codename (e.g., 12 becomes bookworm).
Sources: install.sh:200-363
Package Discovery
The find_package function constructs the URL to locate the correct package on the packages.fluent.do server. The URL follows this pattern:
https://packages.fluent.do/<VERSION>/output/package-<OS>-<OS_VERSION><ARCH_SUFFIX>/<PACKAGE_FILENAME>
<OS>: e.g.,debian,almalinux<OS_VERSION>: e.g.,bookworm,9<ARCH_SUFFIX>: e.g.,.arm64v8for ARM64, or empty for AMD64.<PACKAGE_FILENAME>: e.g.,fluentdo-agent_25.10.1_amd64.deborfluentdo-agent-25.10.1-1.x86_64.rpm.
The script sends a HEAD request to check for the package's existence before attempting to download it.
Sources: install.sh:542-700
Script Customization
The behavior of install.sh can be modified using command-line arguments and environment variables.
Command-Line Arguments
| Argument | Description |
|---|---|
-v, --version VERSION | Install a specific version instead of the latest. |
-i, --interactive | Interactively select a version from a list of available ones. |
-u, --url URL | Use a custom URL for the package repository. |
-l, --log-file FILE | Specify a path for the installation log file. |
-f, --force | Force installation attempt on unsupported distributions. |
-d, --download | Download the package only, without installing it. |
--debug | Enable debug output. |
-h, --help | Show the help message. |
Sources: install.sh:852-882
Environment Variables
| Variable | Description | Default |
|---|---|---|
FLUENTDO_AGENT_URL | Overrides the package repository URL. | https://packages.fluent.do |
LOG_FILE | Overrides the log file location. | $PWD/fluentdo-agent-install.log |
DOWNLOAD_DIR | Overrides the temporary download directory. | $(mktemp -d) |
SUDO | Overrides the sudo command. | sudo |
DISABLE_SUDO | Set to 1 to disable sudo usage. | 0 |
DEBUG | Set to 1 to enable debug output. | 0 |
OS_TYPE, ARCH_TYPE | Overrides detected OS and architecture. | (empty) |
DISTRO_ID, DISTRO_VERSION | Overrides detected Linux distribution. | (empty) |
Sources: install.sh:25-41, 884-892
Building from Source
For advanced use cases or unsupported distributions, FluentDo Agent can be built from source. The project uses CMake as its build system.
Sources: README.md:111-128, source/lib/monkey/CMakeLists.txt:2
Native Compilation
To compile the agent natively on a Linux machine, you need to have the required dependencies (e.g., cmake, make, a C compiler) installed.
The process is as follows:
- Clone the repository.
- Navigate to the
source/builddirectory. - Run
cmake ..to configure the project. - Run
maketo compile the agent.
git clone https://github.com/FluentDo/agent.git
cd agent/source/build
cmake ..
make
The final binary will be located in the build directory.
Sources: README.md:124-128, source/lib/yyjson-0.12.0/doc/doxygen/html/building-and-testing.html:101-104
Pre-Build Setup
Before compilation, the scripts/setup-code.sh script is used to prepare the source tree. This script is essential for creating a correctly versioned build.
Its main responsibilities are:
- Applying Patches: It reads a list of patch files from
patches/patches-agent.filesand applies them to thesource/directory usinggit apply. - Setting Version: It modifies
source/CMakeLists.txtto set the correct version numbers (FLB_VERSION_MAJOR,FLB_VERSION_MINOR,FLB_VERSION_PATCH) based on theFLUENTDO_AGENT_VERSIONenvironment variable. - Updating Package Metadata: It updates package metadata such as
CPACK_PACKAGE_NAMEtofluentdo-agentandCPACK_PACKAGE_VENDORtoFluentDo.
This ensures that the compiled agent and any generated packages have the correct branding and version information.
Sources: scripts/setup-code.sh:24-95
Container-Based Build
The repository includes a script, source/packaging/build.sh, designed to create distributable packages for various Linux targets inside a container. This method avoids polluting the host system with build dependencies.
To build for a specific distribution, use the -d flag:
./source/packaging/build.sh -d rockylinux/9
This command will initiate a containerized build process that compiles the agent and packages it into an RPM or DEB file suitable for the rockylinux/9 target.
Sources: README.md:113-116