Fixed Windows containers building

This commit is contained in:
Alexey Pustovalov 2024-12-30 16:29:20 +00:00
parent e62d67cacf
commit 811ca70689
3 changed files with 61 additions and 49 deletions

View File

@ -14,11 +14,10 @@ ARG MAJOR_VERSION
ARG ZBX_VERSION ARG ZBX_VERSION
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ENV ZABBIX_USER_HOME_DIR="C:\zabbix" \ ENV ZABBIX_USER_HOME_DIR="C:\zabbix" `
ZABBIX_CONF_DIR="C:\zabbix\conf" ZABBIX_CONF_DIR="C:\zabbix\conf"
ENV ZBX_LOADMODULEPATH="${ZABBIX_USER_HOME_DIR}/modules" \ ENV ZBX_USERPARAMETERDIR="${ZABBIX_USER_HOME_DIR}\user_scripts"
ZBX_USERPARAMETERDIR=${ZABBIX_USER_HOME_DIR}/user_scripts
LABEL org.opencontainers.image.title="Zabbix agent" ` LABEL org.opencontainers.image.title="Zabbix agent" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" ` org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -53,7 +52,6 @@ RUN Set-Location -Path $env:SystemDrive\.; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; ` New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; ` New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\buffer | Out-Null; ` New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\buffer | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_LOADMODULEPATH | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_USERPARAMETERDIR | Out-Null; ` New-Item -Force -ItemType directory -Path $env:ZBX_USERPARAMETERDIR | Out-Null; `
` `
net accounts /MaxPWAge:unlimited; ` net accounts /MaxPWAge:unlimited; `

View File

@ -6,11 +6,11 @@ if ($env:DEBUG_MODE -eq "true") {
# Default Zabbix installation name # Default Zabbix installation name
# Default Zabbix server host # Default Zabbix server host
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) { if ($env:ZBX_SERVER_HOST -eq $null) {
$env:ZBX_SERVER_HOST="zabbix-server" $env:ZBX_SERVER_HOST="zabbix-server"
} }
# Default Zabbix server port number # Default Zabbix server port number
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) { if ($env:ZBX_SERVER_PORT -eq $null) {
$env:ZBX_SERVER_PORT="10051" $env:ZBX_SERVER_PORT="10051"
} }
@ -117,35 +117,58 @@ function Update-Config-Multiple-Var {
} }
} }
function File-Process-From-Env {
Param (
[Parameter(Mandatory=$true, Position=0)]
[ValidateNotNullOrEmpty()]
[string] $VarName,
[Parameter(Mandatory=$false, Position=1)]
[string]$FileName = $null,
[Parameter(Mandatory=$false, Position=2)]
[string]$VarValue = $null
)
if (![string]::IsNullOrEmpty($VarValue)) {
$VarValue | Set-Content "$ZabbixInternalEncDir\VarName"
$FileName="$ZabbixInternalEncDir\VarName"
}
if (![string]::IsNullOrEmpty($FileName)) {
Set-Item env:$VarName -Value $FileName
}
$VarName=$VarName -replace 'FILE$'
Write-Host "** $VarName"
Set-Item env:$VarName -Value $null
}
function Prepare-Zbx-Agent-Config { function Prepare-Zbx-Agent-Config {
Write-Host "** Preparing Zabbix agent configuration file"
$ZbxAgentConfig="$env:ZABBIX_CONF_DIR\zabbix_agentd.conf" $ZbxAgentConfig="$env:ZABBIX_CONF_DIR\zabbix_agentd.conf"
if ($env:ZBX_PASSIVESERVERS -eq $null) {
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVESERVERS)) {
$env:ZBX_PASSIVESERVERS="" $env:ZBX_PASSIVESERVERS=""
} }
else { if ($env:ZBX_ACTIVESERVERS -eq $null) {
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
}
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
$env:ZBX_ACTIVESERVERS="" $env:ZBX_ACTIVESERVERS=""
} }
else {
$env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS" if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST) -And ![string]::IsNullOrEmpty($env:ZBX_PASSIVESERVERS)) {
$env:ZBX_PASSIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_PASSIVESERVERS"
}
elseif (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST
} }
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST + ":" + $env:ZBX_SERVER_PORT + $env:ZBX_ACTIVESERVERS if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
Update-Config-Var $ZbxAgentConfig "LogType" "console" $env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
Update-Config-Var $ZbxAgentConfig "LogFile" }
Update-Config-Var $ZbxAgentConfig "LogFileSize" if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL" $env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
Update-Config-Var $ZbxAgentConfig "SourceIP" }
Update-Config-Var $ZbxAgentConfig "LogRemoteCommands" "$env:ZBX_LOGREMOTECOMMANDS" else {
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
}
}
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) { if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
$env:ZBX_PASSIVE_ALLOW="true" $env:ZBX_PASSIVE_ALLOW="true"
@ -153,10 +176,9 @@ function Prepare-Zbx-Agent-Config {
if ($env:ZBX_PASSIVE_ALLOW -eq "true") { if ($env:ZBX_PASSIVE_ALLOW -eq "true") {
Write-Host "** Using '$env:ZBX_PASSIVESERVERS' servers for passive checks" Write-Host "** Using '$env:ZBX_PASSIVESERVERS' servers for passive checks"
Update-Config-Var $ZbxAgentConfig "Server" "$env:ZBX_PASSIVESERVERS"
} }
else { else {
Update-Config-Var $ZbxAgentConfig "Server" Set-Item env:ZBX_PASSIVESERVERS -Value $null
} }
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) { if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
@ -165,29 +187,21 @@ function Prepare-Zbx-Agent-Config {
if ($env:ZBX_ACTIVE_ALLOW -eq "true") { if ($env:ZBX_ACTIVE_ALLOW -eq "true") {
Write-Host "** Using '$env:ZBX_ACTIVESERVERS' servers for active checks" Write-Host "** Using '$env:ZBX_ACTIVESERVERS' servers for active checks"
Update-Config-Var $ZbxAgentConfig "ServerActive" "$env:ZBX_ACTIVESERVERS"
} }
else { else {
Update-Config-Var $ZbxAgentConfig "ServerActive" Set-Item env:ZBX_ACTIVESERVERS -Value $null
} }
# Please use include to enable Alias feature Update-Config-Multiple-Var "$env:ZABBIX_CONF_DIR\zabbix_agentd_item_keys.conf" "DenyKey" "$env:ZBX_DENYKEY"
# update_config_multiple_var $ZBX_AGENT_CONFIG "Alias" $env:ZBX_ALIAS Update-Config-Multiple-Var "$env:ZABBIX_CONF_DIR\zabbix_agentd_item_keys.conf" "AllowKey" "$env:ZBX_ALLOWKEY"
# Please use include to enable Perfcounter feature
# update_config_multiple_var $ZBX_AGENT_CONFIG "PerfCounter" $env:ZBX_PERFCOUNTER
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE" # Update-Config-Multiple-Var "$env:ZABBIX_CONF_DIR\zabbix_agentd_modules.conf" "LoadModule" "$env:LOADMODULE"
Update-Config-Var $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE"
Update-Config-Var $ZbxAgentConfig "TLSCertFile" "$env:ZBX_TLSCERTFILE"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert" "$env:ZBX_TLSCIPHERCERT"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert13" "$env:ZBX_TLSCIPHERCERT13"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK" "$env:ZBX_TLSCIPHERPSK"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK13" "$env:ZBX_TLSCIPHERPSK13"
Update-Config-Var $ZbxAgentConfig "TLSKeyFile" "$env:ZBX_TLSKEYFILE"
Update-Config-Var $ZbxAgentConfig "TLSPSKFile" "$env:ZBX_TLSPSKFILE"
Update-Config-Multiple-Var $ZbxAgentConfig "DenyKey" "$env:ZBX_DENYKEY" File-Process-From-Env "ZBX_TLSCAFILE" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY" File-Process-From-Env "ZBX_TLSCRLFILE" "$env:ZBX_TLSCRLFILE" "$env:ZBX_TLSCRL"
File-Process-From-Env "ZBX_TLSCERTFILE" "$env:ZBX_TLSCERTFILE" "$env:ZBX_TLSCERT"
File-Process-From-Env "ZBX_TLSKEYFILE" "$env:ZBX_TLSKEYFILE" "$env:ZBX_TLSKEY"
File-Process-From-Env "ZBX_TLSPSKFILE" "$env:ZBX_TLSPSKFILE" "$env:ZBX_TLSPSK"
} }
function ClearZbxEnv() { function ClearZbxEnv() {

View File

@ -73,5 +73,5 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_get.exe $env:ZBX_OUTPUT_DIR\bin; ` Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_get.exe $env:ZBX_OUTPUT_DIR\bin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_sender.exe $env:ZBX_OUTPUT_DIR\bin; ` Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_sender.exe $env:ZBX_OUTPUT_DIR\bin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\conf\zabbix_agentd.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.conf_template; ` Copy-Item -Path $env:ZBX_SOURCES_DIR\conf\zabbix_agentd.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.conf_template; `
Copy-Item -Recurse -Path $env:SystemDrive\config_templates\agent $env:ZBX_OUTPUT_DIR\conf\; ` Copy-Item -Recurse -Path $env:SystemDrive\config_templates\agent\* $env:ZBX_OUTPUT_DIR\conf\; `
Write-Host 'Zabbix binaries are compiled...'; Write-Host 'Zabbix binaries are compiled...';