INIT: First commit

This commit is contained in:
2025-09-03 11:21:38 +02:00
commit e50a6d1087
12 changed files with 453 additions and 0 deletions

View File

16
zabbix-apk-builder/.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
# Build artifacts
packages/
*.apk
src/
*.tar.gz
# Docker cache
.docker/
# Backup files
*.backup
*~
# OS files
.DS_Store
Thumbs.db

148
zabbix-apk-builder/APKBUILD Normal file
View File

@@ -0,0 +1,148 @@
# Contributor: Maks <maks@onet.com>
# Maintainer: Maks <maks@onet.com>
pkgname=zabbix
pkgver=7.4.2
pkgrel=0
pkgdesc="Enterprise-class open source distributed monitoring solution"
url="https://www.zabbix.com/"
arch="all"
license="AGPL-3.0-or-later"
options="!check" # No test suite available
makedepends="
autoconf
automake
curl-dev
libevent-dev
libxml2-dev
libtool
linux-headers
net-snmp-dev
openssl-dev
pcre2-dev
sqlite-dev
unixodbc-dev
libssh2-dev
"
pkgusers="zabbix"
pkggroups="zabbix"
install="$pkgname-agent.pre-install $pkgname-proxy.pre-install"
subpackages="$pkgname-agent $pkgname-proxy"
source="https://cdn.zabbix.com/zabbix/sources/stable/${pkgver%.*}/zabbix-$pkgver.tar.gz
zabbix-agent.initd
zabbix-agent.confd
zabbix-proxy.initd
zabbix-proxy.confd
"
builddir="$srcdir/$pkgname-$pkgver"
prepare() {
default_prepare
# Regenerate autotools files
cd "$builddir"
autoreconf -fiv
# Create separate build directories for agent and proxy
cp -r "$builddir" "$srcdir/zabbix-agent-$pkgver"
cp -r "$builddir" "$srcdir/zabbix-proxy-$pkgver"
}
build() {
# Build agent with minimal dependencies
cd "$srcdir/zabbix-agent-$pkgver"
./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--sysconfdir=/etc/zabbix \
--localstatedir=/var \
--enable-agent \
--with-libcurl \
--with-net-snmp \
--with-openssl \
--with-libpcre2
make
# Build proxy with database support
cd "$srcdir/zabbix-proxy-$pkgver"
./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--sysconfdir=/etc/zabbix \
--localstatedir=/var \
--enable-proxy \
--with-libcurl \
--with-net-snmp \
--with-openssl \
--with-libpcre2 \
--with-sqlite3 \
--with-unixodbc \
--with-ssh2 \
--with-libxml2 \
--with-libevent
make
}
package() {
# Meta-package - intentionally empty
# Users install zabbix-agent and/or zabbix-proxy directly
mkdir -p "$pkgdir"
}
agent() {
pkgdesc="Zabbix monitoring agent"
cd "$srcdir/zabbix-agent-$pkgver"
# Install agent binary
install -Dm755 src/zabbix_agent/zabbix_agentd \
"$subpkgdir"/usr/sbin/zabbix_agentd
# Install agent configuration
install -Dm644 conf/zabbix_agentd.conf \
"$subpkgdir"/etc/zabbix/zabbix_agentd.conf
# Install init script and conf
install -Dm755 "$srcdir"/zabbix-agent.initd \
"$subpkgdir"/etc/init.d/zabbix-agent
install -Dm644 "$srcdir"/zabbix-agent.confd \
"$subpkgdir"/etc/conf.d/zabbix-agent
# Create directories
install -dm755 "$subpkgdir"/var/log/zabbix
install -dm755 "$subpkgdir"/var/run/zabbix
}
proxy() {
pkgdesc="Zabbix network monitoring proxy daemon"
cd "$srcdir/zabbix-proxy-$pkgver"
# Install proxy binary
install -Dm755 src/zabbix_proxy/zabbix_proxy \
"$subpkgdir"/usr/sbin/zabbix_proxy
# Install proxy configuration
install -Dm644 conf/zabbix_proxy.conf \
"$subpkgdir"/etc/zabbix/zabbix_proxy.conf
# Install init script and conf
install -Dm755 "$srcdir"/zabbix-proxy.initd \
"$subpkgdir"/etc/init.d/zabbix-proxy
install -Dm644 "$srcdir"/zabbix-proxy.confd \
"$subpkgdir"/etc/conf.d/zabbix-proxy
# Create directories
install -dm755 "$subpkgdir"/var/log/zabbix
install -dm755 "$subpkgdir"/var/run/zabbix
}
sha512sums="
3bf1f915c2cd5a59f1dd3afc10dd1a6e596840e576013839d6eae057cd327893f87cc5cec1d32b6a8ca8bd00735c0070327084aae01dc8d3399202f5a3e365c1 zabbix-7.4.2.tar.gz
SKIP
SKIP
SKIP
SKIP
"

View File

@@ -0,0 +1,40 @@
FROM alpine:latest
# Install build dependencies
RUN apk add --no-cache \
abuild \
alpine-sdk \
autoconf \
automake \
libtool \
linux-headers \
pkgconfig \
sudo \
curl-dev \
libevent-dev \
libxml2-dev \
net-snmp-dev \
openssl-dev \
pcre2-dev \
sqlite-dev \
unixodbc-dev \
zlib-dev \
openldap-dev \
libssh2-dev \
&& adduser -D -G abuild builder \
&& echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Setup build environment
USER builder
WORKDIR /home/builder
# Generate signing keys
RUN abuild-keygen -a -i -n
# Copy package files
COPY --chown=builder:builder . /home/builder/zabbix/
WORKDIR /home/builder/zabbix
# Set build command
CMD ["abuild", "-r"]

View File

@@ -0,0 +1,76 @@
# Zabbix APK Builder
Automated build system for creating Zabbix monitoring packages for Alpine Linux using Docker.
## What it does
This project builds separate Alpine Linux packages for:
- **zabbix-agent** - Monitoring agent for data collection
- **zabbix-proxy** - Network monitoring proxy daemon
- **zabbix** - Meta-package that installs both components
Each package includes proper OpenRC init scripts and user management for production deployment.
## Quick Start
```bash
# Build packages
./build.sh
# Install on Alpine Linux
apk add --allow-untrusted packages/zabbix-agent-*.apk
apk add --allow-untrusted packages/zabbix-proxy-*.apk
# Enable and start services
rc-update add zabbix-agent default
rc-service zabbix-agent start
```
## Configuration
### Change Zabbix Version
Edit `APKBUILD`:
```bash
pkgver=7.4.2 # Change to desired version
```
### Change Architecture
Edit `APKBUILD`:
```bash
arch="all" # All architectures
arch="x86_64" # 64-bit Intel/AMD only
arch="x86_64 aarch64" # 64-bit Intel/AMD and ARM64
```
### Update Checksums
After changing the version:
```bash
# Manual approach
wget https://cdn.zabbix.com/zabbix/sources/stable/X.Y/zabbix-X.Y.Z.tar.gz
sha512sum zabbix-X.Y.Z.tar.gz # Update sha512sums in APKBUILD
# Or let the build system handle it
./build.sh # Will download and verify against official SHA256
```
sha512 is used per Alpine recommendation:
https://wiki.alpinelinux.org/wiki/APKBUILD_Reference
`New packages should use only sha512sums. Support for md5sums and sha1sums was dropped.`
## Build Process
1. **Docker Build**: Creates Alpine Linux build environment
2. **Download Sources**: `abuild checksum` downloads tarball and generates SHA512
2. **Package Build**: Compiles and packages using Alpine's `abuild` system
3. **Output**: Generated APK files in `packages/` directory
## Requirements
- Docker
- Internet connection (for source download and verification)
## Files
- `APKBUILD` - Alpine package definition
- `build.sh` - Build automation script
- `Dockerfile` - Build environment container
- `zabbix-agent.*` - Agent service configuration files
- `zabbix-proxy.*` - Proxy service configuration files

54
zabbix-apk-builder/build.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
set -e
# Configuration
PROJECT_DIR="$(pwd)"
IMAGE_NAME="zabbix-apk-builder"
CONTAINER_NAME="zabbix-build-$$"
OUTPUT_DIR="$PROJECT_DIR/packages"
echo "=== Zabbix APK Builder ==="
echo "Project directory: $PROJECT_DIR"
echo "Output directory: $OUTPUT_DIR"
# Clean up any existing containers
cleanup() {
echo "Cleaning up..."
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
}
trap cleanup EXIT
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Build Docker image
echo "Building Docker image..."
docker build -t "$IMAGE_NAME" "$PROJECT_DIR"
# Run the build in container
echo "Running package build..."
docker run --rm \
--name "$CONTAINER_NAME" \
-v "$OUTPUT_DIR:/output" \
"$IMAGE_NAME" \
sh -c "
set -e
echo 'Starting package build...'
# Generate checksums for APKBUILD
echo 'Generating checksums for APKBUILD...'
abuild checksum
# Build packages
abuild -r
# Copy packages to output
echo 'Copying packages to output directory...'
find /home/builder/packages -name '*.apk' -exec cp {} /output/ \;
"
echo "Build completed successfully!"
echo "To install packages:"
echo " apk add --allow-untrusted $OUTPUT_DIR/zabbix-agent-*.apk"
echo " apk add --allow-untrusted $OUTPUT_DIR/zabbix-proxy-*.apk"

View File

@@ -0,0 +1,11 @@
# Configuration for zabbix-agent
# User and group for the agent
ZABBIX_AGENT_USER="zabbix"
ZABBIX_AGENT_GROUP="zabbix"
# Configuration file location
ZABBIX_AGENT_CONFIG="/etc/zabbix/zabbix_agentd.conf"
# PID file location
ZABBIX_AGENT_PID="/var/run/zabbix/zabbix_agentd.pid"

View File

@@ -0,0 +1,42 @@
#!/sbin/openrc-run
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
extra_commands="checkconfig"
extra_started_commands="reload"
depend() {
need net
use logger
}
: ${ZABBIX_AGENT_USER:=zabbix}
: ${ZABBIX_AGENT_GROUP:=zabbix}
: ${ZABBIX_AGENT_CONFIG:=/etc/zabbix/zabbix_agentd.conf}
: ${ZABBIX_AGENT_PID:=/var/run/zabbix/zabbix_agentd.pid}
command="/usr/sbin/zabbix_agentd"
command_args="-c ${ZABBIX_AGENT_CONFIG}"
command_user="${ZABBIX_AGENT_USER}:${ZABBIX_AGENT_GROUP}"
pidfile="${ZABBIX_AGENT_PID}"
required_files="${ZABBIX_AGENT_CONFIG}"
checkconfig() {
if [ ! -f "${ZABBIX_AGENT_CONFIG}" ] ; then
eerror "You need to create appropriate config file."
return 1
fi
}
start_pre() {
checkconfig || return $?
checkpath --directory --owner ${ZABBIX_AGENT_USER}:${ZABBIX_AGENT_GROUP} --mode 0755 \
$(dirname ${ZABBIX_AGENT_PID}) /var/log/zabbix
}
reload() {
ebegin "Reloading ${SVCNAME}"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}

View File

@@ -0,0 +1,6 @@
#!/bin/sh
addgroup -S zabbix 2>/dev/null
adduser -S -D -H -s /bin/false -G zabbix -g zabbix zabbix 2>/dev/null
exit 0

View File

@@ -0,0 +1,11 @@
# Configuration for zabbix-proxy
# User and group for the proxy
ZABBIX_PROXY_USER="zabbix"
ZABBIX_PROXY_GROUP="zabbix"
# Configuration file location
ZABBIX_PROXY_CONFIG="/etc/zabbix/zabbix_proxy.conf"
# PID file location
ZABBIX_PROXY_PID="/var/run/zabbix/zabbix_proxy.pid"

View File

@@ -0,0 +1,43 @@
#!/sbin/openrc-run
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
extra_commands="checkconfig"
extra_started_commands="reload"
depend() {
need net
use logger
after postgresql mysql
}
: ${ZABBIX_PROXY_USER:=zabbix}
: ${ZABBIX_PROXY_GROUP:=zabbix}
: ${ZABBIX_PROXY_CONFIG:=/etc/zabbix/zabbix_proxy.conf}
: ${ZABBIX_PROXY_PID:=/var/run/zabbix/zabbix_proxy.pid}
command="/usr/sbin/zabbix_proxy"
command_args="-c ${ZABBIX_PROXY_CONFIG}"
command_user="${ZABBIX_PROXY_USER}:${ZABBIX_PROXY_GROUP}"
pidfile="${ZABBIX_PROXY_PID}"
required_files="${ZABBIX_PROXY_CONFIG}"
checkconfig() {
if [ ! -f "${ZABBIX_PROXY_CONFIG}" ] ; then
eerror "You need to create appropriate config file."
return 1
fi
}
start_pre() {
checkconfig || return $?
checkpath --directory --owner ${ZABBIX_PROXY_USER}:${ZABBIX_PROXY_GROUP} --mode 0755 \
$(dirname ${ZABBIX_PROXY_PID}) /var/log/zabbix
}
reload() {
ebegin "Reloading ${SVCNAME}"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}

View File

@@ -0,0 +1,6 @@
#!/bin/sh
addgroup -S zabbix 2>/dev/null
adduser -S -D -H -s /bin/false -G zabbix -g zabbix zabbix 2>/dev/null
exit 0