mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-02-10 06:50:00 +01:00
Fixed Windows containers building
This commit is contained in:
parent
e62d67cacf
commit
811ca70689
@ -14,11 +14,10 @@ ARG MAJOR_VERSION
|
||||
ARG ZBX_VERSION
|
||||
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"
|
||||
|
||||
ENV ZBX_LOADMODULEPATH="${ZABBIX_USER_HOME_DIR}/modules" \
|
||||
ZBX_USERPARAMETERDIR=${ZABBIX_USER_HOME_DIR}/user_scripts
|
||||
ENV ZBX_USERPARAMETERDIR="${ZABBIX_USER_HOME_DIR}\user_scripts"
|
||||
|
||||
LABEL org.opencontainers.image.title="Zabbix agent" `
|
||||
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_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:ZBX_LOADMODULEPATH | Out-Null; `
|
||||
New-Item -Force -ItemType directory -Path $env:ZBX_USERPARAMETERDIR | Out-Null; `
|
||||
`
|
||||
net accounts /MaxPWAge:unlimited; `
|
||||
|
@ -6,11 +6,11 @@ if ($env:DEBUG_MODE -eq "true") {
|
||||
|
||||
# Default Zabbix installation name
|
||||
# Default Zabbix server host
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
|
||||
if ($env:ZBX_SERVER_HOST -eq $null) {
|
||||
$env:ZBX_SERVER_HOST="zabbix-server"
|
||||
}
|
||||
# Default Zabbix server port number
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) {
|
||||
if ($env:ZBX_SERVER_PORT -eq $null) {
|
||||
$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 {
|
||||
Write-Host "** Preparing Zabbix agent configuration file"
|
||||
|
||||
$ZbxAgentConfig="$env:ZABBIX_CONF_DIR\zabbix_agentd.conf"
|
||||
if ($env:ZBX_PASSIVESERVERS -eq $null) {
|
||||
$env:ZBX_PASSIVESERVERS=""
|
||||
}
|
||||
if ($env:ZBX_ACTIVESERVERS -eq $null) {
|
||||
$env:ZBX_ACTIVESERVERS=""
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVESERVERS)) {
|
||||
$env:ZBX_PASSIVESERVERS=""
|
||||
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST) -And ![string]::IsNullOrEmpty($env:ZBX_PASSIVESERVERS)) {
|
||||
$env:ZBX_PASSIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_PASSIVESERVERS"
|
||||
}
|
||||
else {
|
||||
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
|
||||
elseif (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
|
||||
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST
|
||||
}
|
||||
|
||||
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
|
||||
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
|
||||
$env:ZBX_ACTIVESERVERS=""
|
||||
}
|
||||
else {
|
||||
$env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS"
|
||||
}
|
||||
|
||||
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST + ":" + $env:ZBX_SERVER_PORT + $env:ZBX_ACTIVESERVERS
|
||||
|
||||
Update-Config-Var $ZbxAgentConfig "LogType" "console"
|
||||
Update-Config-Var $ZbxAgentConfig "LogFile"
|
||||
Update-Config-Var $ZbxAgentConfig "LogFileSize"
|
||||
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
|
||||
Update-Config-Var $ZbxAgentConfig "SourceIP"
|
||||
Update-Config-Var $ZbxAgentConfig "LogRemoteCommands" "$env:ZBX_LOGREMOTECOMMANDS"
|
||||
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
|
||||
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
|
||||
$env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
|
||||
}
|
||||
if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
|
||||
$env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
|
||||
}
|
||||
else {
|
||||
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
|
||||
}
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
|
||||
$env:ZBX_PASSIVE_ALLOW="true"
|
||||
@ -153,10 +176,9 @@ function Prepare-Zbx-Agent-Config {
|
||||
|
||||
if ($env:ZBX_PASSIVE_ALLOW -eq "true") {
|
||||
Write-Host "** Using '$env:ZBX_PASSIVESERVERS' servers for passive checks"
|
||||
Update-Config-Var $ZbxAgentConfig "Server" "$env:ZBX_PASSIVESERVERS"
|
||||
}
|
||||
else {
|
||||
Update-Config-Var $ZbxAgentConfig "Server"
|
||||
Set-Item env:ZBX_PASSIVESERVERS -Value $null
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
|
||||
@ -165,29 +187,21 @@ function Prepare-Zbx-Agent-Config {
|
||||
|
||||
if ($env:ZBX_ACTIVE_ALLOW -eq "true") {
|
||||
Write-Host "** Using '$env:ZBX_ACTIVESERVERS' servers for active checks"
|
||||
Update-Config-Var $ZbxAgentConfig "ServerActive" "$env:ZBX_ACTIVESERVERS"
|
||||
}
|
||||
else {
|
||||
Update-Config-Var $ZbxAgentConfig "ServerActive"
|
||||
Set-Item env:ZBX_ACTIVESERVERS -Value $null
|
||||
}
|
||||
|
||||
# Please use include to enable Alias feature
|
||||
# update_config_multiple_var $ZBX_AGENT_CONFIG "Alias" $env:ZBX_ALIAS
|
||||
# Please use include to enable Perfcounter feature
|
||||
# update_config_multiple_var $ZBX_AGENT_CONFIG "PerfCounter" $env:ZBX_PERFCOUNTER
|
||||
Update-Config-Multiple-Var "$env:ZABBIX_CONF_DIR\zabbix_agentd_item_keys.conf" "DenyKey" "$env:ZBX_DENYKEY"
|
||||
Update-Config-Multiple-Var "$env:ZABBIX_CONF_DIR\zabbix_agentd_item_keys.conf" "AllowKey" "$env:ZBX_ALLOWKEY"
|
||||
|
||||
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE"
|
||||
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 "$env:ZABBIX_CONF_DIR\zabbix_agentd_modules.conf" "LoadModule" "$env:LOADMODULE"
|
||||
|
||||
Update-Config-Multiple-Var $ZbxAgentConfig "DenyKey" "$env:ZBX_DENYKEY"
|
||||
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY"
|
||||
File-Process-From-Env "ZBX_TLSCAFILE" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
|
||||
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() {
|
||||
|
@ -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_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 -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...';
|
||||
|
Loading…
Reference in New Issue
Block a user