Files
zabbix-docker/templates/entrypoints/java-gateway.sh
Alexey Pustovalov b8fed86d78
Some checks failed
Build images (DockerHub) / Initialize build (push) Has been cancelled
Build images (DockerHub) / Build base on ${{ matrix.os }} (push) Has been cancelled
Build images (DockerHub) / Build ${{ matrix.build }} base on ${{ matrix.os }} (push) Has been cancelled
Build images (DockerHub) / Build ${{ matrix.build }} on ${{ matrix.os }} (push) Has been cancelled
Build images (RedHat) / Initialize build (push) Has been cancelled
Build images (RedHat) / Build ${{ matrix.build }} base (${{ matrix.arch }}) (push) Has been cancelled
Build images (RedHat) / Build ${{ matrix.build }} image (${{ matrix.arch }}) (push) Has been cancelled
Build images (RedHat) / Clear images cache (${{ matrix.arch }}) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
SonarCloud analysis / Analysis (push) Has been cancelled
Prepare to remove supervisord
2026-04-13 21:28:21 +09:00

83 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
readonly ENTRYPOINT_LIBS="/usr/lib/docker-entrypoint"
source "${ENTRYPOINT_LIBS}/debug.sh"
source "${ENTRYPOINT_LIBS}/logging.sh"
: "${JAVA:=/usr/bin/java}"
readonly ZBX_GATEWAY_CONFIG="${ZABBIX_CONF_DIR}/zabbix_java_gateway_logback.xml"
readonly ZABBIX_JAVA_DIR="/usr/sbin/zabbix_java"
build_classpath() {
local classpath
local jar
classpath="lib"
while IFS= read -r -d '' jar; do
classpath="${classpath}:$jar"
done < <(find lib bin ext_lib -name '*.jar' -print0)
printf '%s\n' "$classpath"
}
update_config() {
info "** Preparing Zabbix Java Gateway log configuration file"
[[ -f "$ZBX_GATEWAY_CONFIG" ]] || error "Missing configuration file: $ZBX_GATEWAY_CONFIG"
: "${ZBX_DEBUGLEVEL:=info}"
info "Updating ${ZBX_GATEWAY_CONFIG} 'DebugLevel' parameter: '${ZBX_DEBUGLEVEL}'... updated"
sed -i -e "/^.*<root level=/s/=.*/=\"${ZBX_DEBUGLEVEL}\">/" "$ZBX_GATEWAY_CONFIG"
}
run_service() {
info "** Preparing Zabbix Java Gateway"
: "${ZBX_TIMEOUT:=3}"
update_config
cd "$ZABBIX_JAVA_DIR"
local classpath
classpath="$(build_classpath)"
local -a java_opts=(
-server
"-Dlogback.configurationFile=${ZBX_GATEWAY_CONFIG}"
)
if [[ -n "${ZBX_JAVA_OPTS:-}" ]]; then
read -r -a extra_java_opts <<< "${ZBX_JAVA_OPTS}"
java_opts+=("${extra_java_opts[@]}")
fi
local -a zabbix_opts=(
"-Dsun.rmi.transport.tcp.responseTimeout=${ZBX_TIMEOUT}000"
"-Dzabbix.listenPort=${ZBX_LISTEN_PORT:-10052}"
"-Dzabbix.timeout=${ZBX_TIMEOUT}"
"-Dzabbix.pidFile=/tmp/java_gateway.pid"
)
[[ -n "${ZBX_LISTEN_IP:-}" ]] && zabbix_opts+=("-Dzabbix.listenIP=${ZBX_LISTEN_IP}")
[[ -n "${ZBX_START_POLLERS:-}" ]] && zabbix_opts+=("-Dzabbix.startPollers=${ZBX_START_POLLERS}")
[[ -n "${ZBX_PROPERTIES_FILE:-}" ]] && zabbix_opts+=("-Dzabbix.propertiesFile=${ZBX_PROPERTIES_FILE}")
local -a cmd=(
"$JAVA"
"${java_opts[@]}"
-classpath "$classpath"
"${zabbix_opts[@]}"
com.zabbix.gateway.JavaGateway
)
exec "${cmd[@]}"
}
if [[ $# -eq 0 || "${1:-}" == -* ]]; then
run_service
fi
exec "$@"