Compare commits
43 Commits
e50a6d1087
...
d7f1052305
| Author | SHA1 | Date | |
|---|---|---|---|
| d7f1052305 | |||
| 8ab7ff54b9 | |||
| 993104e122 | |||
| 44a3bc1cf4 | |||
| 44b4aa9e7a | |||
| 7986278926 | |||
| a1752e68c7 | |||
| f3ac36a139 | |||
| f95de88005 | |||
| 9f2e966662 | |||
| baf814e0e5 | |||
|
|
0722d1942f | ||
| 1119a38496 | |||
| 91afa98d6b | |||
| f3ce93f8b1 | |||
| 7bb7bfc3a5 | |||
| 5e70da801f | |||
| 7b0392a98c | |||
|
|
bb33667302 | ||
| ead031ac44 | |||
|
|
a41dbfeed3 | ||
| 8ccc13c7bb | |||
| 5e685381cb | |||
| 4b8c91d957 | |||
| 089935525b | |||
| 17fc3cdbb8 | |||
| a39a23597c | |||
| ebf3b5b9dd | |||
| d980f67ee4 | |||
| 8efb9ecb08 | |||
| 4aea91ce6e | |||
| 7e1b131dba | |||
| f8576b1b5f | |||
| c99b2b6c13 | |||
| e64bdef6d9 | |||
| f07025ba40 | |||
| 050c9ee235 | |||
| 91e0fe6180 | |||
| c731d61550 | |||
| cfb5f0b4e6 | |||
| cda7a45371 | |||
| b28feea59f | |||
| ba372cd76d |
260
.gitea/workflows/build.yaml
Normal file
260
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
name: Zabbix APK Builder
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Trigger on pushes to main/test branch
|
||||||
|
push:
|
||||||
|
branches: [ main, test ]
|
||||||
|
paths: [ 'zabbix-apk-builder/**' ]
|
||||||
|
|
||||||
|
# Scheduled check for new versions (daily at 6 AM UTC)
|
||||||
|
schedule:
|
||||||
|
- cron: '0 6 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Skip the execution if the commit message contains [ci skip]
|
||||||
|
if: ${{ gitea.event.head_commit.author.name != 'Gitea Action' }}
|
||||||
|
outputs:
|
||||||
|
should_build: ${{ steps.version-check.outputs.should_build }}
|
||||||
|
latest_version: ${{ steps.version-check.outputs.latest_version }}
|
||||||
|
current_version: ${{ steps.version-check.outputs.current_version }}
|
||||||
|
is_push_trigger: ${{ steps.version-check.outputs.is_push_trigger }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check for new Zabbix version
|
||||||
|
id: version-check
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Install jq for JSON parsing (remove sudo for container environment)
|
||||||
|
apt-get update && apt-get install -y jq
|
||||||
|
|
||||||
|
# Detect trigger type
|
||||||
|
if [[ "${{ gitea.event_name }}" == "push" ]]; then
|
||||||
|
echo "is_push_trigger=true" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Triggered by push event - force build"
|
||||||
|
else
|
||||||
|
echo "is_push_trigger=false" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Triggered by schedule - check version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get current version from APKBUILD
|
||||||
|
CURRENT_VERSION=$(grep '^pkgver=' zabbix-apk-builder/APKBUILD | cut -d'=' -f2)
|
||||||
|
echo "current_version=${CURRENT_VERSION}" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Current version: ${CURRENT_VERSION}"
|
||||||
|
|
||||||
|
# Get latest version from Zabbix API (stable releases only)
|
||||||
|
LATEST_VERSION=$(curl -s "https://git.zabbix.com/rest/api/1.0/projects/ZBX/repos/zabbix/tags?limit=100" | \
|
||||||
|
jq -r '.values[].displayId' | \
|
||||||
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | \
|
||||||
|
grep -v 'rc\|beta\|alpha' | \
|
||||||
|
sort -V | \
|
||||||
|
tail -1)
|
||||||
|
|
||||||
|
echo "latest_version=${LATEST_VERSION}" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Latest version: ${LATEST_VERSION}"
|
||||||
|
|
||||||
|
# Determine if we should build based on trigger type
|
||||||
|
if [[ "${{ gitea.event_name }}" == "push" ]]; then
|
||||||
|
# Push trigger: always build to test changes
|
||||||
|
echo "should_build=true" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Build required: Push trigger detected"
|
||||||
|
elif [[ "${CURRENT_VERSION}" != "${LATEST_VERSION}" ]]; then
|
||||||
|
# Schedule trigger: only build if version changed
|
||||||
|
echo "should_build=true" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Build required: New version ${LATEST_VERSION} available"
|
||||||
|
else
|
||||||
|
# Schedule trigger: no new version
|
||||||
|
echo "should_build=false" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "No build required: Version ${CURRENT_VERSION} is current"
|
||||||
|
fi
|
||||||
|
|
||||||
|
update-version:
|
||||||
|
needs: check-version
|
||||||
|
# Only update version during scheduled runs when new version is available
|
||||||
|
if: ${{ needs.check-version.outputs.should_build == 'true' && needs.check-version.outputs.is_push_trigger == 'false' && needs.check-version.outputs.current_version != needs.check-version.outputs.latest_version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Update APKBUILD version
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
LATEST_VERSION="${{ needs.check-version.outputs.latest_version }}"
|
||||||
|
CURRENT_VERSION="${{ needs.check-version.outputs.current_version }}"
|
||||||
|
|
||||||
|
echo "Updating APKBUILD from ${CURRENT_VERSION} to ${LATEST_VERSION}"
|
||||||
|
|
||||||
|
# Update pkgver
|
||||||
|
sed -i "s/^pkgver=.*/pkgver=${LATEST_VERSION}/" zabbix-apk-builder/APKBUILD
|
||||||
|
|
||||||
|
# Reset pkgrel to 0 for new version
|
||||||
|
sed -i "s/^pkgrel=.*/pkgrel=0/" zabbix-apk-builder/APKBUILD
|
||||||
|
|
||||||
|
# Clear checksums (will be regenerated during build)
|
||||||
|
sed -i 's/^sha512sums=.*/sha512sums="SKIP"/' zabbix-apk-builder/APKBUILD
|
||||||
|
|
||||||
|
# Commit changes with [ci skip] to prevent recursive triggers
|
||||||
|
git config --local user.email "action@gitea.com"
|
||||||
|
git config --local user.name "Gitea Action"
|
||||||
|
git add zabbix-apk-builder/APKBUILD
|
||||||
|
git commit -m "AUTO: Update Zabbix to version ${LATEST_VERSION} [ci skip]" || exit 0
|
||||||
|
git push
|
||||||
|
|
||||||
|
build-packages:
|
||||||
|
# Build packages after version update (for scheduled runs) or immediately (for push runs)
|
||||||
|
needs: [check-version, update-version]
|
||||||
|
# Run if should_build=true AND either update-version ran successfully OR it was skipped due to push trigger
|
||||||
|
if: ${{ needs.check-version.outputs.should_build == 'true' && (success() || needs.check-version.outputs.is_push_trigger == 'true') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# Use token to ensure we get the latest version if it was updated
|
||||||
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
ref: ${{ gitea.ref }}
|
||||||
|
|
||||||
|
- name: Pull latest changes if version was updated
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Pull any version updates that may have been committed
|
||||||
|
if [[ "${{ needs.check-version.outputs.is_push_trigger }}" == "false" ]]; then
|
||||||
|
echo "Scheduled build - pulling latest changes"
|
||||||
|
git pull origin "${GITEA_REF_NAME:-main}" || true
|
||||||
|
else
|
||||||
|
echo "Push build - using current ref"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Verify build environment
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "=== Build Environment ==="
|
||||||
|
echo "Trigger type: ${{ gitea.event_name }}"
|
||||||
|
echo "Current branch: $(git branch --show-current)"
|
||||||
|
echo "APKBUILD version: $(grep '^pkgver=' zabbix-apk-builder/APKBUILD | cut -d'=' -f2)"
|
||||||
|
echo "Target version: ${{ needs.check-version.outputs.latest_version }}"
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build Zabbix packages
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd zabbix-apk-builder
|
||||||
|
chmod +x build.sh
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
- name: Verify and list built packages
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "=== Verifying package build ==="
|
||||||
|
cd zabbix-apk-builder
|
||||||
|
|
||||||
|
if [[ ! -d "packages" ]]; then
|
||||||
|
echo "❌ ERROR: packages directory does not exist"
|
||||||
|
echo "Current directory contents:"
|
||||||
|
ls -la .
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for packages in the standard Alpine directory structure
|
||||||
|
PACKAGE_DIRS=(
|
||||||
|
"packages/*.apk"
|
||||||
|
"packages/builder/x86_64/*.apk"
|
||||||
|
"packages/x86_64/*.apk"
|
||||||
|
)
|
||||||
|
|
||||||
|
FOUND_PACKAGES=false
|
||||||
|
for pattern in "${PACKAGE_DIRS[@]}"; do
|
||||||
|
if ls $pattern >/dev/null 2>&1; then
|
||||||
|
FOUND_PACKAGES=true
|
||||||
|
echo "✅ Packages found in: $(dirname $pattern)"
|
||||||
|
ls -la $pattern
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$FOUND_PACKAGES" == "false" ]]; then
|
||||||
|
echo "❌ ERROR: No packages found in any expected location"
|
||||||
|
echo "Directory structure:"
|
||||||
|
find packages -type f -name "*.apk" 2>/dev/null || echo "No .apk files found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Package details ==="
|
||||||
|
find packages -name "*.apk" -exec bash -c 'echo "Package: $(basename "$1")"; echo "Size: $(du -h "$1" | cut -f1)"; echo "---"' _ {} \;
|
||||||
|
|
||||||
|
- name: Upload packages as artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: zabbix-apk-packages-${{ gitea.run_number }}
|
||||||
|
path: |
|
||||||
|
zabbix-apk-builder/packages/**/*.apk
|
||||||
|
!zabbix-apk-builder/packages/**/APKINDEX.tar.gz
|
||||||
|
retention-days: 30
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
deploy-test:
|
||||||
|
needs: [check-version, build-packages]
|
||||||
|
if: ${{ needs.check-version.outputs.should_build == 'true' && contains(gitea.ref, 'test') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download packages
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: zabbix-apk-packages
|
||||||
|
path: packages/
|
||||||
|
|
||||||
|
- name: Test deployment in Alpine container
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "=== Testing package installation ==="
|
||||||
|
|
||||||
|
# Verify packages were downloaded
|
||||||
|
if [[ ! -d "packages" ]] || [[ -z "$(ls -A packages/ 2>/dev/null)" ]]; then
|
||||||
|
echo "ERROR: No packages found for testing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test agent package
|
||||||
|
if ls packages/zabbix-agent-*.apk >/dev/null 2>&1; then
|
||||||
|
echo "Testing agent package..."
|
||||||
|
docker run --rm -v "${PWD}/packages:/packages" alpine:latest sh -c "
|
||||||
|
apk add --allow-untrusted /packages/zabbix-agent-*.apk
|
||||||
|
which zabbix_agentd
|
||||||
|
zabbix_agentd --version
|
||||||
|
" && echo "✅ Agent test passed" || echo "❌ Agent test failed"
|
||||||
|
else
|
||||||
|
echo "⚠️ No agent package found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test proxy package
|
||||||
|
if ls packages/zabbix-proxy-*.apk >/dev/null 2>&1; then
|
||||||
|
echo "Testing proxy package..."
|
||||||
|
docker run --rm -v "${PWD}/packages:/packages" alpine:latest sh -c "
|
||||||
|
apk add --allow-untrusted /packages/zabbix-proxy-*.apk
|
||||||
|
which zabbix_proxy
|
||||||
|
zabbix_proxy --version
|
||||||
|
" && echo "✅ Proxy test passed" || echo "❌ Proxy test failed"
|
||||||
|
else
|
||||||
|
echo "⚠️ No proxy package found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Package deployment test completed"
|
||||||
1
zabbix-apk-builder/.gitignore
vendored
1
zabbix-apk-builder/.gitignore
vendored
@@ -9,6 +9,7 @@ src/
|
|||||||
|
|
||||||
# Backup files
|
# Backup files
|
||||||
*.backup
|
*.backup
|
||||||
|
*.bak
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# OS files
|
# OS files
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Contributor: Maks <maks@onet.com>
|
# Contributor: Maksym Buz <maksym.buz@zabbix.com>
|
||||||
# Maintainer: Maks <maks@onet.com>
|
# Maintainer: Maksym Buz <maksym.buz@zabbix.com>
|
||||||
pkgname=zabbix
|
pkgname=zabbix
|
||||||
pkgver=7.4.2
|
pkgver=7.4.2
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc="Enterprise-class open source distributed monitoring solution"
|
pkgdesc="Enterprise-class open source distributed monitoring solution"
|
||||||
url="https://www.zabbix.com/"
|
url="https://www.zabbix.com/"
|
||||||
arch="all"
|
arch="all"
|
||||||
license="AGPL-3.0-or-later"
|
license="AGPL-3.0-only"
|
||||||
options="!check" # No test suite available
|
options="!check" # No test suite available
|
||||||
makedepends="
|
makedepends="
|
||||||
autoconf
|
autoconf
|
||||||
@@ -140,9 +140,5 @@ proxy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sha512sums="
|
sha512sums="
|
||||||
3bf1f915c2cd5a59f1dd3afc10dd1a6e596840e576013839d6eae057cd327893f87cc5cec1d32b6a8ca8bd00735c0070327084aae01dc8d3399202f5a3e365c1 zabbix-7.4.2.tar.gz
|
|
||||||
SKIP
|
|
||||||
SKIP
|
|
||||||
SKIP
|
|
||||||
SKIP
|
SKIP
|
||||||
"
|
"
|
||||||
@@ -36,5 +36,32 @@ COPY --chown=builder:builder . /home/builder/zabbix/
|
|||||||
|
|
||||||
WORKDIR /home/builder/zabbix
|
WORKDIR /home/builder/zabbix
|
||||||
|
|
||||||
|
# Create build script that just builds packages
|
||||||
|
USER root
|
||||||
|
RUN cat > /usr/local/bin/build-packages.sh << 'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Building packages as builder user..."
|
||||||
|
sudo -u builder sh -c "
|
||||||
|
cd /home/builder/zabbix
|
||||||
|
echo 'Generating checksums...'
|
||||||
|
abuild checksum
|
||||||
|
echo 'Building packages...'
|
||||||
|
abuild -r
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "Build complete! Packages built in /home/builder/packages:"
|
||||||
|
find /home/builder/packages -name "*.apk" -exec ls -la {} \;
|
||||||
|
|
||||||
|
echo "Setting proper permissions on packages..."
|
||||||
|
chmod 644 /home/builder/packages/*.apk 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "Final package list (excluding APKINDEX):"
|
||||||
|
find /home/builder/packages -name "*.apk" -exec ls -la {} \;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/build-packages.sh
|
||||||
|
|
||||||
# Set build command
|
# Set build command
|
||||||
CMD ["abuild", "-r"]
|
CMD ["/usr/local/bin/build-packages.sh"]
|
||||||
@@ -1,76 +1,195 @@
|
|||||||
# Zabbix APK Builder
|
# Zabbix APK Builder
|
||||||
|
|
||||||
Automated build system for creating Zabbix monitoring packages for Alpine Linux using Docker.
|
Automated Alpine Linux package builder for Zabbix Agent and Proxy with CI/CD pipeline integration.
|
||||||
|
|
||||||
## What it does
|
## Features
|
||||||
|
|
||||||
This project builds separate Alpine Linux packages for:
|
- 🔄 **Automatic Version Detection**: Monitors Zabbix releases using official Bitbucket API
|
||||||
- **zabbix-agent** - Monitoring agent for data collection
|
- 🏗️ **Docker-based Building**: Consistent, reproducible builds in isolated environment
|
||||||
- **zabbix-proxy** - Network monitoring proxy daemon
|
- 🚀 **CI/CD Pipeline**: Full automation from version detection to package deployment
|
||||||
- **zabbix** - Meta-package that installs both components
|
- 📦 **Multi-package Support**: Builds agent and proxy packages
|
||||||
|
- 🧪 **Automated Testing**: Tests package installation in Alpine containers
|
||||||
Each package includes proper OpenRC init scripts and user management for production deployment.
|
- 📊 **Gitea Integration**: Publishes packages to Gitea repository
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
|
### 1. Repository Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Build packages
|
# Clone this repository
|
||||||
|
git clone https://git.mbuz.uk/mbuz/Zabbix.git
|
||||||
|
cd zabbix-apk-builder
|
||||||
|
|
||||||
|
# Make build script executable
|
||||||
|
chmod +x build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Manual Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build packages locally
|
||||||
./build.sh
|
./build.sh
|
||||||
|
|
||||||
# Install on Alpine Linux
|
# Packages will be in ./packages/
|
||||||
apk add --allow-untrusted packages/zabbix-agent-*.apk
|
ls -la packages/
|
||||||
apk add --allow-untrusted packages/zabbix-proxy-*.apk
|
```
|
||||||
|
|
||||||
# Enable and start services
|
### 3. CI/CD Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run the setup script
|
||||||
|
./setup-cicd.sh
|
||||||
|
|
||||||
|
# Follow the prompts to configure GitHub secrets
|
||||||
|
```
|
||||||
|
|
||||||
|
## Package Information
|
||||||
|
|
||||||
|
### Built Packages
|
||||||
|
|
||||||
|
1. **zabbix-agent** - Zabbix Agent only
|
||||||
|
2. **zabbix-proxy** - Zabbix Proxy
|
||||||
|
3. **zabbix** - Meta package
|
||||||
|
|
||||||
|
### Current Version
|
||||||
|
|
||||||
|
- **Zabbix Version**: 7.4.2
|
||||||
|
- **Alpine Base**: latest
|
||||||
|
- **Architecture**: all
|
||||||
|
|
||||||
|
## CI/CD Pipeline
|
||||||
|
|
||||||
|
### Automatic Triggers
|
||||||
|
|
||||||
|
- **Daily**: Checks for new Zabbix versions at 6 AM UTC
|
||||||
|
- **Push**: Builds when code changes in main/test branches
|
||||||
|
- **Manual**: Force builds via Gitea Actions
|
||||||
|
|
||||||
|
### Version Detection
|
||||||
|
|
||||||
|
Uses Zabbix Bitbucket API:
|
||||||
|
```bash
|
||||||
|
https://git.zabbix.com/rest/api/1.0/projects/ZBX/repos/zabbix/tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### Pipeline Jobs
|
||||||
|
|
||||||
|
1. **check-version**: Detects new Zabbix releases
|
||||||
|
2. **update-version**: Updates APKBUILD automatically
|
||||||
|
3. **build-packages**: Builds APK packages
|
||||||
|
4. **publish-to-gitea**: Deploys to your repository
|
||||||
|
5. **deploy-test**: Tests installation (test branch)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### GitHub Secrets Required
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GITEA_SSH_KEY # SSH private key for Gitea access
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
└── zabbix-git
|
||||||
|
└── zabbix-apk-builder
|
||||||
|
├── .gitea/workflows # Workflows for Gitea actions
|
||||||
|
├── .gitignore # Ignore files
|
||||||
|
├── APKBUILD # APKBUILD file for Zabbix
|
||||||
|
├── Dockerfile # Dockerfile for building packages
|
||||||
|
├── README.md # Project description
|
||||||
|
├── build.sh # Script for manual builds
|
||||||
|
├── packages/ # Directory for built packages
|
||||||
|
├── zabbix-agent.* # Agent configuration files
|
||||||
|
└── zabbix-proxy.* # Proxy configuration files
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Install Packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Add repository
|
||||||
|
echo "http://gitea-repo/mbuz/Zabbix/raw/branch/main/alpine/v3.18/main" >> /etc/apk/repositories
|
||||||
|
|
||||||
|
# Update and install
|
||||||
|
apk update
|
||||||
|
apk add zabbix-agent
|
||||||
|
|
||||||
|
# Enable and start
|
||||||
rc-update add zabbix-agent default
|
rc-update add zabbix-agent default
|
||||||
rc-service zabbix-agent start
|
rc-service zabbix-agent start
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
### Configuration
|
||||||
|
|
||||||
### Change Zabbix Version
|
|
||||||
Edit `APKBUILD`:
|
|
||||||
```bash
|
```bash
|
||||||
pkgver=7.4.2 # Change to desired version
|
# Configure agent
|
||||||
|
vim /etc/zabbix/zabbix_agentd.conf
|
||||||
|
|
||||||
|
# Set server IP
|
||||||
|
Server=your.zabbix.server
|
||||||
|
|
||||||
|
# Restart service
|
||||||
|
rc-service zabbix-agent restart
|
||||||
```
|
```
|
||||||
|
|
||||||
### Change Architecture
|
## Development
|
||||||
Edit `APKBUILD`:
|
|
||||||
|
### Local Testing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
arch="all" # All architectures
|
# Test build locally
|
||||||
arch="x86_64" # 64-bit Intel/AMD only
|
./build.sh
|
||||||
arch="x86_64 aarch64" # 64-bit Intel/AMD and ARM64
|
|
||||||
|
# Test in Docker
|
||||||
|
docker run --rm -it \
|
||||||
|
-v $(pwd)/packages:/packages \
|
||||||
|
alpine:3.18 sh -c "
|
||||||
|
apk add --allow-untrusted /packages/zabbix-agent-*.apk
|
||||||
|
zabbix_agentd --version
|
||||||
|
"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Update Checksums
|
### Branch Strategy
|
||||||
After changing the version:
|
|
||||||
|
- **main**: Production releases, auto-deployed
|
||||||
|
- **test**: Testing and validation, no auto-deploy
|
||||||
|
|
||||||
|
### Making Changes
|
||||||
|
|
||||||
|
1. Create feature branch from `test`
|
||||||
|
2. Test changes thoroughly
|
||||||
|
3. Merge to `test` for CI validation
|
||||||
|
4. Merge to `main` for production release
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Build Issues
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Manual approach
|
# Check build logs
|
||||||
wget https://cdn.zabbix.com/zabbix/sources/stable/X.Y/zabbix-X.Y.Z.tar.gz
|
docker logs $(docker ps -l -q)
|
||||||
sha512sum zabbix-X.Y.Z.tar.gz # Update sha512sums in APKBUILD
|
|
||||||
# Or let the build system handle it
|
# Manual build debug
|
||||||
./build.sh # Will download and verify against official SHA256
|
docker run -it --rm -v $(pwd):/build alpine:3.18 sh
|
||||||
|
cd /build && ./build.sh
|
||||||
```
|
```
|
||||||
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
|
### Version Detection
|
||||||
|
|
||||||
1. **Docker Build**: Creates Alpine Linux build environment
|
```bash
|
||||||
2. **Download Sources**: `abuild checksum` downloads tarball and generates SHA512
|
# Test API manually
|
||||||
2. **Package Build**: Compiles and packages using Alpine's `abuild` system
|
curl -s "https://git.zabbix.com/rest/api/1.0/projects/ZBX/repos/zabbix/tags?limit=100" | \
|
||||||
3. **Output**: Generated APK files in `packages/` directory
|
jq -r '.values[].displayId' | \
|
||||||
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+
|
||||||
|
| \
|
||||||
|
sort -V | tail -1
|
||||||
|
```
|
||||||
|
|
||||||
## Requirements
|
## License
|
||||||
|
|
||||||
- Docker
|
This project follows the same license as Zabbix (AGPLv3).
|
||||||
- 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
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
PROJECT_DIR="$(pwd)"
|
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
IMAGE_NAME="zabbix-apk-builder"
|
IMAGE_NAME="zabbix-apk-builder"
|
||||||
CONTAINER_NAME="zabbix-build-$$"
|
CONTAINER_NAME="zabbix-build-$$"
|
||||||
OUTPUT_DIR="$PROJECT_DIR/packages"
|
OUTPUT_DIR="$PROJECT_DIR/packages"
|
||||||
@@ -12,43 +12,46 @@ echo "=== Zabbix APK Builder ==="
|
|||||||
echo "Project directory: $PROJECT_DIR"
|
echo "Project directory: $PROJECT_DIR"
|
||||||
echo "Output directory: $OUTPUT_DIR"
|
echo "Output directory: $OUTPUT_DIR"
|
||||||
|
|
||||||
# Clean up any existing containers
|
# Clean up function
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "Cleaning up..."
|
echo "Cleaning up container..."
|
||||||
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
|
docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
# Create output directory
|
# Clean and create output directory
|
||||||
|
rm -rf "$OUTPUT_DIR"
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
# Build Docker image
|
# Build Docker image
|
||||||
echo "Building Docker image..."
|
echo "Building Docker image..."
|
||||||
docker build -t "$IMAGE_NAME" "$PROJECT_DIR"
|
docker build -t "$IMAGE_NAME" "$PROJECT_DIR"
|
||||||
|
|
||||||
# Run the build in container
|
# Run the build in the container
|
||||||
echo "Running package build..."
|
echo "Running package build in container..."
|
||||||
docker run --rm \
|
docker run --name "$CONTAINER_NAME" "$IMAGE_NAME"
|
||||||
--name "$CONTAINER_NAME" \
|
|
||||||
-v "$OUTPUT_DIR:/output" \
|
|
||||||
"$IMAGE_NAME" \
|
|
||||||
sh -c "
|
|
||||||
set -e
|
|
||||||
echo 'Starting package build...'
|
|
||||||
|
|
||||||
# Generate checksums for APKBUILD
|
# Copy packages from container to host
|
||||||
echo 'Generating checksums for APKBUILD...'
|
echo "Copying packages from container..."
|
||||||
abuild checksum
|
if docker cp "$CONTAINER_NAME:/home/builder/packages/." "$OUTPUT_DIR/"; then
|
||||||
|
echo "✅ Packages copied successfully"
|
||||||
|
|
||||||
# Build packages
|
# Remove APKINDEX files (we only want the .apk packages)
|
||||||
abuild -r
|
echo "Removing repository index files..."
|
||||||
|
find "$OUTPUT_DIR" -name "APKINDEX.tar.gz" -delete 2>/dev/null || true
|
||||||
|
|
||||||
# Copy packages to output
|
# Fix permissions on copied files
|
||||||
echo 'Copying packages to output directory...'
|
echo "Fixing file permissions..."
|
||||||
find /home/builder/packages -name '*.apk' -exec cp {} /output/ \;
|
find "$OUTPUT_DIR" -name "*.apk" -exec chmod 644 {} \; 2>/dev/null || true
|
||||||
"
|
|
||||||
echo "Build completed successfully!"
|
echo "Build completed successfully!"
|
||||||
echo "To install packages:"
|
echo "Packages are in $OUTPUT_DIR:"
|
||||||
echo " apk add --allow-untrusted $OUTPUT_DIR/zabbix-agent-*.apk"
|
find "$OUTPUT_DIR" -name "*.apk" -exec ls -la {} \;
|
||||||
echo " apk add --allow-untrusted $OUTPUT_DIR/zabbix-proxy-*.apk"
|
else
|
||||||
|
echo "❌ Failed to copy packages"
|
||||||
|
echo "Checking what's in the container..."
|
||||||
|
docker exec "$CONTAINER_NAME" find /home/builder -name "*.apk" -exec ls -la {} \; 2>/dev/null || true
|
||||||
|
docker exec "$CONTAINER_NAME" ls -la /home/builder/packages/ 2>/dev/null || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user